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
ld error
Re:ld error
Um.. I don't think I understand you clearly.. would you post the code?
Cheers
Cheers
Re:ld error
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.
Just including the header doesn't tell the linker which file contains the code.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ld error
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)
- 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)