@abalaban
Quote:
So my advise would be to - if you want to generate both - to to it in two passes (one for shared and one for static) rather than in a single one.
This is particularly important. libtool would sort that out for you when it's working, but if not. The object files for a shared object *cannot* *mustnot* be used in static library and vice verca.
@Raziel
Building the two are quite different.
If you have a bunch of c files you want to turn into libs by hand:
Shared objects are built with gcc the files must be compiled with the -fPIC option *very important*.
eg.
gcc -o myobj.os myobj.c -fPIC <rest of CFLGS>
then combined with
gcc -o mysharedobj.so -shared myobj.os myotherobj.os mythirdobj.os -lrequiredlib -lrequiredlib
using the .os extention isn't required but helps to stop accidental mixing object files between static and non static buiilds.
Static libs are build with 'ar'
build the object files without -fPIC *very important*
then combine them with ar
ar mystaticlib.a myobj.o myotherobj.o mythirdobj.o
IMHO you not use shared libs unless you need to load modules dynamically, or combine it with something like python.