I have a very specific case of Linker error :
'Invoking: GCC C++ Linker 4 [arm-linux-gnueabihf]' arm-linux-gnueabihf-g++ -lpthread ./src/FPGA_Peripherals/AUX_IMU/AUX_IMU_functions.o
./src/main.o: In function main': ../src/main.cpp:7: undefined reference to `function()'
the error output is truncated for purpose of this post. The error and the object, where the function definitions lies, is highlighted.
The code is compiled and linked using DS-5 C/C++ Eclipse Platform, with the GCC 4.x [arm-linux-gnueabihd] (DS-5 built-in) tool-chain :
- GCC C++ Compiler 4 [arm-linux-gnueabihf]
- GCC C Compiler 4 [arm-linux-gnueabihf]
- GCC Assembler 4 [arm-linux-gnueabihf]
- GCC C Linker 4 [arm-linux-gnueabihf]
- GCC C++ Linker 4 [arm-linux-gnueabihf]
- GCC Archiver 4 [arm-linux-gnueabihf]
With Gnu Make Builder.
Source code is structured in folders :
src
main.cpp
FPGA_peripherals
- AUX_IMU
header.h
AUX_IMU_functions.c
Minimalistic code producing the error :
main.cpp
#include "header.h"
int main() {
function();
return 0;
}
header.h
void function(void);
AUX_IMU_functions.c
#include "header.h"
void function(void){
int i = 3;
};
The C code is correctly compiled using GCC C Compiler 4 [arm-linux-gnueabihf]. The C++ code (other files, not included within this example), are correctly compiled using GCC C++ Linker 4 [arm-linux-gnueabihf].
This apparently is not a Linker related problem, but what else to check, if Linker still produces this error ?
The error disappears, once I re-name the files to .hpp and .cpp. Why is that ? Does GCC C and GCC C++ produces incompatible .o objects ?