Linking dynamic a static libraries
Eljay Love-Jensen
eljay@adobe.com
Thu Jan 13 12:30:00 GMT 2005
Hi Roman,
With GCC, you should be able to do something like this:
gcc -o myexecutable \
-v \
*.c \
-Wl,-Bstatic \
-lfirst \
-lsecond \
-Wl,-Bdynamic \
-lthird
The compiler will link to libfirst.a and libsecond.a (both static), and
libthird.so and the support libraries (dynamic).
The -v will display the magic-behind-the-curtains, and you'll see that the
linker step is adding in (your mileage may vary) ...
crt0.o, crtbegin.o, and crtend.o
some compiler specific or system library paths
-lstdc++
-lgcc
-lcygwin
-luser32
-lkernel32
-ladvapi32
-lshell32
-lgcc
You'll also see where the -Bstatic and -Bdynamic are affecting library linkage.
HTH,
--Eljay
More information about the Gcc-help
mailing list