Undefined Reference to a function
I'm using Linux and I have the following files: main.c, main.h fileA.c, fileA.h fileB.cpp, fileB.h The function F1() is declared in fileB.h and defined in fileB.cpp . I need to use the function in fileA.c , and so I declared the function as extern void F1(); in fileA.c . However, during compilation, I got the error fileA.c: (.text+0x2b7): undefined reference to `F1' What is wrong? Thank you. ETA: Thanks to the answers I've received, I now have the following: In fileA.h, I have #include fileB.h #include main.h #ifdef __cplusplus extern "C" #endif void F1(); In fileA.c, I have #include fileA.h