[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Static linking doesn't work



Havoc Pennington <hp@redhat.com> writes:

> "Felix E. Klee" <felix.klee@inka.de> writes:
>> 
>> compiling my GTK-application worked fine until I added the -static flag
>> to gcc. Now, I get many error messages that look like this:
>>     /usr/lib/libgtkmm.a(accellabel.o): In function
>> `Gtk::AccelLabel::isA(Gtk::Object *)':
>> accellabel.o(.text+0x1a8): undefined reference to
>> `gtk_accel_label_get_type'
>> 
>> Here are the libraries that I include:
>> -lgtk -lgdk -lgtkmm -lgdkmm -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm
>> -lsigc -lpthread -lgthread -lgtkextramm -lgtkextra
>> 
>> What am I doing wrong?
>> 
> 
> Static linking cares about the order of the libraries on the link
> line. They should be ordered according to dependency. I don't remember
> the direction - either library A that depends on B must come before B,
> or vice versa.
> 
> In any case, you have it mixed up - the right thing is one of these 
> two orders:
>   -lgtkmm -lgtk -lX11
> or:
>   -lX11 -lgtk -lgtkmm
> not:
>   -lgtk -lgtkmm -lX11
>  
> A quick look at the gcc docs should tell you which order to use.

And with static linking you may also have to do insane things like put
-lX11 multiple times on the command line.  Feh.

-bp
-- 
Ceterum censeo vi esse delendam




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]