I write a static library: libA.a. I have another application called B.o. B.o doesn’t used any functions in libA.a. I want to combine libA.o into B.o, then I could call some stuff in libA.a by other methods, when B.o is running.
I write makefile like this: gcc B.c -o B.o -lA -u symbol_A. Here -u is from GCC manual:
http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
It suggests use -u to force linking unused library, and symbol_A is some symbol in libA.a
But it doesn’t work. After linking, I can not find any LibA.a’s stuff in B.o.
May anyone give me some hint?
p.s I am using GCC 3.4.4, eclipse+CDT under windows, and B.o will be deployed under linux.
The explanation of the
-uflag from GCC means the following:So if your
B.chas nothing that may be defined inlibA.athe-uflag won’t help you since thesymbol_Ais not needed byB.cand by the same tokenB.o, so will be simply ignored.