Re: [gtk-list] Re: Static binary
- From: Erik Mouw <J A K Mouw its tudelft nl>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Static binary
- Date: Fri, 10 Sep 99 11:10:57 +0200
On Fri, 10 Sep 1999 15:34:49 +0900, Maxim Marin wrote:
> Erik Mouw wrote:
>
>> On Wed, 08 Sep 1999 15:42:52 +0900, Maxim Marin wrote:
>> > I need to make a static binary of my Gtk++ program. Unfortunately just
>> > passing -static to compiler will not work. gmodule depends on dlopen,
>> > dlclose...
>>
>> What OS are you using? Creating static linked binaries is not a trivial
>> task. Also show the command you use to link a dynamically linked binary,
>> maybe we just can tell add option "....".
>
> I am developing on Solaris, with either Sun CC or g++ compiler. (The two of
> them work, but I prefer Sun CC) the command is:
Hmm, I'm not quite sure if "gcc -static" works on Solaris machines. It
segfaults on a SunOS 4.1.4 system, but that was with gcc-2.8.1 (I have not
yet installed gcc-2.95.1). "gcc -static" is only known to work in all
cases on Linux systems. Oh, and I hope you know that you can't mix objects
from different C++ compilers.
> CC -B static *bunch-of-objects* -o myBinary-L/usr/local/lib -L/opt/X11R6.4/lib
> -R/opt/X11R6.4/lib -lgtk -lgdk -lgmodule -lglib -ldl -lXext -lX11 -lsocket
> -lnsl -lm (these are supplied by gtk-config --libs)
The trick in these things is to alternate between static and dynamic
linking. You probably only want to link the GTK+ libraries to be static,
because you can assume that the system libraries are avaliable dynamically
on every Solaris system. Assumed that "-B static" turns on static linking
and "-B dynamic" dynamic linking (I don't have a Solaris system to try),
your link line should look like:
CC *bunch-of-objects* -o myBinary -L/usr/local/lib -L/opt/X11R6.4/lib \
-R/opt/X11R6.4/lib -B static -lgtk -lgdk -lgmodule -lglib -B dynamic \
-ldl -B static -lXext -lX11 -B dynamic -lsocket -lnsl -lm
This should link gtk, gdk, gmodule, glib, Xext, and X11 statically and the
other libraries dynamically.
Hope this helps,
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]