Making a static lib from objects + static libs

Kovacs Peter Tamas p.kovacs at holografika.com
Tue Dec 18 15:09:27 GMT 2007


Dear all,

I am trying to make a library that uses my other static libraries.

This new library is a separate KDevelop project, and my older static
libraries can be found in sdk/HoloSDK/lib/ in the home dir.
So I've created a Librool library (libHoloSDK.la), and in the Target 
Options window, on the Libraries tab, I've added to LIBADD:
../../../sdk/HoloSDK/lib/libHGeometry.a
../../../sdk/HoloSDK/lib/libHCore.a
etc

When I compile this PublicHoloSDK project, it succeeds.

------------------------------------
...
/bin/sh ../libtool --tag=CXX --mode=link g++ -O2 -g0 -o libHoloSDK.la 
-rpath /usr/local/lib holoCore.lo holoLightfield.lo -lpthread 
../../../sdk/HoloSDK/lib/libHGeometry.a 
../../../sdk/HoloSDK/lib/libHNetwork.a 
../../../sdk/HoloSDK/lib/libHCore.a ../../../sdk/HoloSDK/lib/libHMath.a
<br />
*** Warning: Linking the shared library libHoloSDK.la against the
*** static library ../../../sdk/HoloSDK/lib/libHGeometry.a is not portable!
<br />
*** Warning: Linking the shared library libHoloSDK.la against the
*** static library ../../../sdk/HoloSDK/lib/libHNetwork.a is not portable!
<br />
*** Warning: Linking the shared library libHoloSDK.la against the
*** static library ../../../sdk/HoloSDK/lib/libHCore.a is not portable!
<br />
*** Warning: Linking the shared library libHoloSDK.la against the
*** static library ../../../sdk/HoloSDK/lib/libHMath.a is not portable!
g++ -shared -nostdlib 
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64/crti.o 
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/crtbeginS.o .libs/holoCore.o 
.libs/holoLightfield.o -lpthread ../../../sdk/HoloSDK/lib/libHGeometry.a 
../../../sdk/HoloSDK/lib/libHNetwork.a 
../../../sdk/HoloSDK/lib/libHCore.a ../../../sdk/HoloSDK/lib/libHMath.a 
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5 
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib 
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64 
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../.. -L/lib/../lib64 
-L/usr/lib/../lib64 /usr/lib64/libstdc++.so -lm -lc -lgcc_s 
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/crtendS.o 
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64/crtn.o -O2 
-g0 -Wl,-soname -Wl,libHoloSDK.0 -o .libs/libHoloSDK.0.0.0
(cd .libs && rm -f libHoloSDK.0 && ln -s libHoloSDK.0.0.0 libHoloSDK.0)
(cd .libs && rm -f libHoloSDK && ln -s libHoloSDK.0.0.0 libHoloSDK)
ar cru .libs/libHoloSDK.a ../../../sdk/HoloSDK/lib/libHGeometry.a 
../../../sdk/HoloSDK/lib/libHNetwork.a 
../../../sdk/HoloSDK/lib/libHCore.a ../../../sdk/HoloSDK/lib/libHMath.a 
holoCore.o holoLightfield.o ../../../sdk/HoloSDK/lib/libHGeometry.a 
../../../sdk/HoloSDK/lib/libHNetwork.a 
../../../sdk/HoloSDK/lib/libHCore.a ../../../sdk/HoloSDK/lib/libHMath.a
ranlib .libs/libHoloSDK.a
creating libHoloSDK.la
(cd .libs && rm -f libHoloSDK.la && ln -s ../libHoloSDK.la libHoloSDK.la)
gmake[2]: Nothing to be done for `all-am'.
*** Success ***
------------------------------------

It creates the following files in PublicHoloSDK/optimized/src/.libs:
libHoloSDK (symlink)
libHoloSDK.0 (symlink)
libHoloSDK.0.0.0
libHoloSDK.a
libHoloSDK.la (symlink to ../libHoloSDK.la)
libHoloSDK.lai
and some *.o files


Now if I copy the resulting files to /usr/local/lib64 and try to create 
an app based on this library, and it picks up the static version, it 
cannot find _any_ of the symbols that were in the older static libs.

When I try and look at the lib with nm, I can see the symbols that are 
coming from the object files, but cannot see any of the symbols coming 
from the static libs.
And I also have some error messages:
nm: libHGeometry.a: File format not recognized
nm: libHNetwork.a: File format not recognized
nm: libHCore.a: File format not recognized
nm: libHMath.a: File format not recognized

from which my guess is that nm "blindly" packs my static libs into the 
new static lib, however the assumption is that a static lib should 
consist of object files, right?
So how could I set my project up so that the static lib will finally 
contain all the symbols?
(I could write a script that unpacks the objects, then repacks them, but 
I assume there is a simpler way I don't know about)
 
Thanks for your kind help in advance,
Peter





More information about the KDevelop mailing list