Referencia indefinida a una función
Estoy usando Linux y tengo los siguientes archivos:
main.c, main.h
fileA.c, fileA.h
fileB.cpp, fileB.h
La funciónF1()
se declara enfileB.h
y definido enfileB.cpp
. Necesito usar la función enfileA.c
, y entonces declare la función como
extern void F1();
infileA.c
.
Sin embargo, durante la compilación, recibí el error
fileA.c: (.text+0x2b7): undefined reference to `F1'
¿Qué está mal
Gracias
ETA: Gracias a las respuestas que recibí, ahora tengo lo siguiente:
In fileA.h, tengo
#include fileB.h
#include main.h
#ifdef __cplusplus
extern "C"
#endif
void F1();
In fileA.c, tengo
#include fileA.h
In fileB.h, tengo
extern "C" void F1();
In fileB.cpp, tengo
#include "fileB.h"
extern "C" void F1()
{ }
Sin embargo, ahora tengo el error
fileB.h: error: expected identifier or '(' before string constant