How to avoding compiling unreferenced code into .o target file

kipade kipade@163.com
Thu Aug 31 09:37:00 GMT 2017


Hi all,
If there is a way to avoiding assemblly unreferenced entry into .o 
target file?
The issue is from such condition:
Dynamic library B is dependent on Dynamic library A: the source find b.c in
library B includes a header file from A, which named a.h, here, there was a
inlined function within a.h, however, b.c just include a.h and without any
code decleared within a.h.  So, the target .o file of b.c would not generate
any code for the inline function, just leave an entry for that function.

The problem is, when the b.c was packed as a shared dynamic library and
was used by the third executable client, gcc would complain it can't find
the reference of the inline function entry decleared in a.h, although which
would not be used by the library B.

Finnaly, I have to remove the include instruction in b.c to avoiding such
linking error. But, I don't know how to resolve that issue if there is a c.c
which have to include a.h because it use parts of entries decleared in
a.h. (I can't modify any code of library A, because it's a foreign library)

Any hints will be very very appreciated.
Thanks all.




More information about the Gcc-help mailing list