SW4STM32 (Eclipse based) won't link Source and Header [message #1741462] |
Thu, 25 August 2016 11:11 |
luu tec Messages: 11 Registered: August 2016 |
Junior Member |
|
|
hi
im currently working on a project for a stm32l4 mcu with system workbench 4 stm32.
i created a cpp project, it is automatically converted to a cpp project and adds the gcc and g++ compiler.
i added the path of header files both to the gcc and the g++, even if it will choose the g++.
somehow, the workbench is not able to link the source file and the header file.
see example below, when i add the source (.cpp) as shown in the main.cpp, the project compiles properly. when i just add the header file, it cant link the classes function prototype the the declaration in the source file.
---------------------------------------------------------------------
main.cpp:
---------------------------------------------------------------------
#include "comPoint.hpp"
//#include "comPoint.cpp" // with this it works!
ComPoint * p1 = new ComPoint;
int main(void)
{
for(;;);
}
---------------------------------------------------------------------
comPoint.hpp:
---------------------------------------------------------------------
/* Guard symbol --------------------------------------------------------------*/
#ifndef COMPOINT_HPP_
#define COMPOINT_HPP_
/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
/* Class definition ----------------------------------------------------------*/
class ComPoint
{
public:
ComPoint(void);
ComPoint(uint8_t initX, uint8_t initY);
~ComPoint(void);
void SetPoint(ComPoint p);
void SetX(uint8_t x);
void SetY(uint8_t y);
uint8_t GetX(void);
uint8_t GetY(void);
private:
uint8_t xCoord;
uint8_t yCoord;
};
#endif /* COMPOINT_HPP_ */
---------------------------------------------------------------------
comPoint.cpp:
---------------------------------------------------------------------
/* Includes ------------------------------------------------------------------*/
#include <comPoint.hpp>
/* Object function definitions -----------------------------------------------*/
// constructor of the object
ComPoint::ComPoint(void)
: xCoord(0), yCoord(0)
{
}
// constructor of the object
ComPoint::ComPoint(uint8_t initX, uint8_t initY)
: xCoord(initX), yCoord(initY)
{
}
// destructor of the object
ComPoint::~ComPoint(void)
{
}
-
Attachment: error.png
(Size: 1.57KB, Downloaded 385 times)
|
|
|
Re: SW4STM32 (Eclipse based) won't link Source and Header [message #1741552 is a reply to message #1741462] |
Thu, 25 August 2016 18:58 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
The problem is that you are referencing an external object file from main. The workbench doesn't link source and headers files ever. What it does is produce a procedure (via a make file). The make file is run by make (or the internal make emulator) which will compile each source then, using the linker, link them together.
When you included the source file you placed all of the ComPoint routines in the main object file so there was nothing to link outside of system libraries.
Normally, Eclipse will compile all of the sources in a project and link their objects. I don't know why it wouldn't in your case.
The configuration of your project and what you are actually doing is unclear.
Is it part of your project? Does it show in the Project view?
What your image has is a summary from the Problems and Errors view.
Can you show the build log? It contains the actual messages and their sequence.
Start with clean project ( Project --> Clean ... ) then build the project ( Project --> Build Project ) and show us the build log.
[Updated on: Thu, 25 August 2016 19:01] Report message to a moderator
|
|
|
Re: SW4STM32 (Eclipse based) won't link Source and Header [message #1741564 is a reply to message #1741552] |
Thu, 25 August 2016 20:40 |
luu tec Messages: 11 Registered: August 2016 |
Junior Member |
|
|
hi david
thanks for you response.
here the log file and error output.
i did reboot the osx, clean the project, rebuild the index, double check all include paths,.. although, i did not change any compiler settings/flags/.. since i have no knowledge of compiler settings. it was just a project created by the workbench.
i also did try to compile the project on a windows 7 setup, same result though.
ah and yes. it is a folder in the same path as inc, src,.. and is part of the project. no issue there.
[Updated on: Thu, 25 August 2016 20:45] Report message to a moderator
|
|
|
Re: SW4STM32 (Eclipse based) won't link Source and Header [message #1741574 is a reply to message #1741564] |
Fri, 26 August 2016 00:38 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
hmmm ... Your initial post had a much simpler example with two files (main.cpp and ComPoint.cpp). Now you are showing many more. Why the switch?
The linker command:
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T"/Users/username/Desktop/REPOS/STM32_Projects/2016_002_STM32L4Disco_TestProject/Software/T_STM32L4_Disco/LinkerScript.ld" -Wl,-Map=output.map -Wl,--gc-sections -fno-exceptions -fno-rtti -lm -o "T_STM32L4_Disco.elf" @"objects.list"
seems to include all of the objects ( @"objects.list" ) but I don't see it being built and don't know its contents. The '@' actually means to read more options from this file. Where did it get built and what are the contents?
My guess: there one or more missing objects. Specifcally, whatever contains the missing functions MwGPO::MwGPO(GPIO_TypeDef*, unsigned short) and MwGPO::Toggle() and any I may have missed.
Can you provide the build log from your original example?
The reason for asking for a clean build was so that I could see the compilation of main.cpp and ComPoint.cpp along with the link instead of an incremental build or mere link. If it is using objects.list or an equivalent I would need to see it also to know all of the options being given the linker,
[Updated on: Fri, 26 August 2016 08:44] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04303 seconds