Linking dependencies into static library / Partial linking

Philip K.F. Hölzenspies
Tue Jan 8 13:26:00 GMT 2008


This may be a newbe question and it may already have been answered on this 
mailing lists, in which case I may have used the wrong search terms. If this 
is the case, I would be very satisfied with a reference to the relevant 
thread. The problem is the following.

I am currently developing a program in C called RTSM. Someone else has written 
a program, called HEBE, in C++. RTSM should use some of the code from HEBE. 
To develop independently, I would like to write a C wrapper for HEBE and 
compile HEBE with this wrapper to a static library to which I could link my 
RTSM. For reasons I will not bore you with too much, I would really like to 
have HEBE as a single static library with no further link dependencies. HEBE 
links with glpk, so I would like to link in libglpk.a in some way. When I 
compile HEBE as

gcc <misc_options> -lglpk *.cc -o hebe.o

the resulting object file still contains undefined symbols from glpk, i.e. nm 
reports (randomly selected line for example):

U _glp_lpx_add_cols

whereas "nm /usr/local/lib/libglpk.a | grep x_add_cols" outputs:

         U _glp_lpx_add_cols
         U _glp_lpx_add_cols
00001020 T _glp_lpx_add_cols
         U _glp_lpx_add_cols
         U _glp_lpx_add_cols
         U _glp_lpx_add_cols
         U _glp_lpx_add_cols

I would expect there to be some "XXX T _glp_lpx_add_cols" in hebe.o, but there 

In the end, I would really like to have a libhebe.a file that only exports the 
symbols of the wrapper AND does not contain unresolved / undefined symbols 
that impose linker dependencies. Is this at all possible?


More information about the Binutils mailing list