Hi,
MCF5282, CW 6.3
I get the following error when trying to build my project.
Link Error : Undefined : <function name>
The calling function is in a file which contains the relevant .h file and right-clicking on the function name allows me to jump to the relevant peice of code.
The code compiles OK, and works in another project.
Does anyone have any ideas on how to track down the source of the error?
Although the 2 projects are different, the order in which the relevant files are linked is the same.
Thanks
Paul
Solved! Go to Solution.
To call functions implemented in C++ from C code, the C++ code has to explictely use C linkage.
So there has to be something like this in the header file:
// ApplicationTasks.h// ....#ifdef __cplusplusextern "C" {#endifextern int input_get(void); #ifdef __cplusplus}#endif
Paul,
this error indicates that the linker is not able to find implementation of a function in the project.
1. I'd suggest you first to check if the file that includes this function is available for Linker.
("Linking Order" tab of project inspector)
2. Perhaps IDE cache is not up-to-date so try to remove all object code (Ctrl -)and rebuild.
3. please verify that called function is not "static"
If it doesn't help could you post here complete Linker error message?
Stanish
Hi Stanish, thanks for replying.
1. Yes the file does appear in the Link Order Tab.
2. I have tried removing all of the object code but this still doesn't help.
3. The function is not static.
The message is: -
Link Error : Undefined : "input_get"
Referenced from "DigitalInput_Get" in digital_io.c
The function being called resides in a file called ApplicationTasks.cpp and I have tried moving this above the calling file in the Link order tab, but this made no difference.
Basically, I have several projects which use common device drivers (such as digital_io.c) and application specific code (such as ApplicationTasks.cpp). The linking works in another application (seperate CW project)
Paul
To call functions implemented in C++ from C code, the C++ code has to explictely use C linkage.
So there has to be something like this in the header file:
// ApplicationTasks.h// ....#ifdef __cplusplusextern "C" {#endifextern int input_get(void); #ifdef __cplusplus}#endif
Many Thanks Stanish. That was the problem.
Regards
Paul