Re: Static compilation of hello world



On Fri, Jun 20, 2003 at 11:05:22AM +0200, Patricia Balbastre Betoret wrote:
gcc `pkg-config --libs --cflags gtk+-2.0`  -static -o base-static base.c
/tmp/ccwW8hUR.o(.text+0x1c): In function `main':
: undefined reference to `gtk_init'
/tmp/ccwW8hUR.o(.text+0x29): In function `main':
: undefined reference to `gtk_window_new'
/tmp/ccwW8hUR.o(.text+0x3a): In function `main':
: undefined reference to `gtk_widget_show'
/tmp/ccwW8hUR.o(.text+0x42): In function `main':
: undefined reference to `gtk_main'
collect2: ld returned 1 exit status
make: *** [static] Error 1

And I suppose that now this has to be with the static option ... I really do 
not know how to solve it ... Help!!!

The order of libraries / object files given on GCCs command line is
significant. I guess that GCC does not reorder the arguments when it
passes them to ld. The linker will only link in object files which
provide something that was referenced in some file it has seen before.

Try specifying your source file as the first argument on GCCs command
line: 

gcc base.c `pkg-config --libs --cflags gtk+-2.0`  -static -o base-static

HTH
-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux user                         - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \



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