c++ - Convert a Static Library to a Shared Library (create libsome.so from libsome.a): where's my symbols? -
The title of this question is one, but the answer to that question does not help me.
I have a bunch of packed object files in the stable library:
% g ++ -std = c ++ 98 -fpic -g -O1 -c - O foo.o foo.cpp% G ++ -std = c ++ 98 -fpic -g -O1 -c -o-bar.o bar.cpp% ar -rc libsome.a foo.o bar.o
I want to generate libsome.a from libsome.a instead of 'd object files, but library actually barebones:
% G ++ -std = c ++ 98 -fpic -g -O1 -shared -o libsome.so libsome.a% nm -DC libsome.so 0000xxxx a _DYNAMIC 0000xxxx a _GLOBAL_OFFSET_TABLE_w _Jv_RegisterClasses 0000xxxx __bss_start w __cxa_finalize 0000xxxx a _edata 0000xxxx A _0000xxxx T _fini 0000xxxx T _init
Fixed The class room is fine, or at least I am able to fully link it to the executable and it is able to run the inherent functionality, even if I make libsome.so from foo.o and bar.o everything is fine .
By assuming this, you are using GNU Linker, you specify - we-collect option There is a need to do so that you can get all the contents of the stable collection. Since this is a linkir option, you will need - to tell GCC to pass it with the linker:
G ++ -STD = C ++ 98 -fpic -g -O1 -shared - o libsome.so-wl, - archive archive libsome.a
If you were doing some more complex, where you want all the libraries, but libsome only part of library support , You would like to use it on libsome after closing the entire archive:
... -Wl, - full-archive libsome.a-Wl, - no-flood If you are not using the GNU linker, what you need to see your linker supports it and its name is. On Sun Linker, it is called -z allextract
and -z defaultextract
.
Comments
Post a Comment