Page 1 of 1

ld error

Posted: Sat Jul 24, 2004 5:53 pm
by firas981
ld reported a message like :
"undefiend reference f in file mainfile.c "
f is a function declared in a header , say : "file.h" and I included it in mainfile.c !!

when I put
#include "file.c" instead of #include "file.h" , things go right !

thanks

Re:ld error

Posted: Sat Jul 24, 2004 6:17 pm
by Adek336
Um.. I don't think I understand you clearly.. would you post the code?
Cheers

Re:ld error

Posted: Sat Jul 24, 2004 6:33 pm
by Curufir
Err, short on details, but maybe because you aren't actually compiling/linking mainfile.c with file.c?

Just including the header doesn't tell the linker which file contains the code.

Re:ld error

Posted: Mon Aug 02, 2004 2:13 am
by Pype.Clicker
The proper approach is to
- include the header stuff.h in the main.c file
- compile both stuff.c and main.c files separately (-c)
- link them together (ld stuff.o main.o)