Hi guys!
Thanks a lot for your answers. I have only two questions:
1. In GCC manual I have found completely different explanation of compilation option -B (see http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Directory-Options.html#Directory-Options and I could not find explanation for option -Bstatic and -Bdynamic). I am using GCC 3.3.2 and OS SunOS rel. 5.9.
2. I am linking some static libraries (i.e. library code should be added to executable file or ?) but I think executable file size is too small (if I compare it with size of static libraries). Here is statement for creating of my executable:
gcc -o executable_name -v ObjectFile1.o ObjectFile2.o -L/opt/sybase/OCS-12_0/lib
-L/opt/builds/libraries -lm -lsocket -lnsl -ldl -laio -W1,-Bstatic -lct -lcs -ltcl -lcomn -lintl -lblk -W1,-Bdynamic -W1,-Bstatic -ltmpsyb -lssclstd -W1,-Bdynamic
Size of executable_name file is about 129KB. But static libraries which I am linking e.g. libct.a (1,032KB), libcs.a (122KB), libtcl.a (537KB), libcomn.a (749KB), libintl.a (82KB), libblk.a (166KB). Is it OK the size of the executable? I thought that size of executable must be much bigger (if you look at sizes of the static libraries). Or am I doing (or understanding) something wrong?
Thanks a lot for your help.
Regards, Roman.
From: lrtaylor@xxxxxxxxxx To: <eljay@xxxxxxxxx>, <roman_pagac@xxxxxxxxxxx>, <gcc-help@xxxxxxxxxxx> Subject: RE: Linking dynamic a static libraries Date: Thu, 13 Jan 2005 10:29:42 -0700
Actually, you may want to put the static libraries last and then end your command line with a final -Wl,-Bdynamic:
gcc -o myexecutable \ -v \ *.c \ -Wl,-Bdynamic \ -lfirst \ -lsecond \ -Wl,-Bstatic \ -lthird \ -Wl,-Bdynamic
This is because if your dynamic libraries depend on symbols from your static libraries, they might not get picked up if you put the static libraries first. The final -Wl,-Bdynamic will allow it to link in the standard libraries normally.
Thanks, Lyle
-----Original Message----- From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of Eljay Love-Jensen Sent: Thursday, January 13, 2005 5:31 AM To: Roman Pagac; gcc-help@xxxxxxxxxxx Subject: Re: Linking dynamic a static libraries
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
_________________________________________________________________
Rozhodnite o tom, kto si s vami moze vymienat spravy a povedzte priatelom o MSN Messenger. http://messenger.msn.sk/