[LCP] How to do intremental linking with gcc and ld
Bryan Christ
bryan.christ at gmail.com
Sat Jun 20 11:48:34 EST 2009
I have a top-level directory from which I want to share as common code
with two different applications (a client and a server). I thought it
would be quite easy to create a combined object file in the common
directory and then link to it from each of the individual programs.
While I don't have any problem compiling the larger common object
file, I have having unresolved symbols when I try to link the two
different programs to it.
Here is how I am creating the common object file:
gcc -c $(CFLAGS) $(INCLUDES) $(DEFS) *.c
ld -r -o common_tools.o *.o
And here is how I try to link against the common object file:
gcc -c $(CFLAGS) $(INCLUDES) $(LIBS) $(NORMAL_DEFS) *.c
ld -o myprogram *.o ../../common/common_tools.o
I'm sure I'm missing something trivial but don't know what that is.
Thank in advance to anyone who helps.
--
Bryan
<><
More information about the linuxCprogramming
mailing list