Re: Compile with static




Allan Nielsen <an@kampsax.dtu.dk> writes:

> Hi,
> 
> I tried to compile a program I've made with the -static parameter, and the
> linker could'nt find any of the gtk-fuctions - is there a special hint??
> (I have got the .a and .la togethger with the .so libs)
 
I suspect the problem is that you aren't specifying the other
libraries that GTK needs. (Shared libraries can, on ELF platforms,
specify dependencies, but static libraries can't.)

You'll have to do something like:

gcc -o myprog myprog.o -static -lgtk -lgdk -lglib \
    -L/usr/X11R6/lib/ -lX11 -lXext -lm

> And how do I build with gtk-libs static while glibc dynamic??

This is somewhat system dependent. On Linux-ELF, using gcc,
it works to do:

gcc -o myprog myprog.o -Wl,-Bstatic -lgtk -lgdk -lglib -Wl,-Bdynamic \
    -L/usr/X11R6/lib/ -lX11 -lXext -lm

(Move the -Wl,-Bdynamic to the end if you want the X libraries static
as well)

Regards,
                                        Owen



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