On Mon, Jan 08, 2007 at 11:10:16AM +0100, Steven Scholz wrote:
> As I wrote I have problems linking it statically!
>
> gcc -Wall -O2 -lpthread -lrt cyclictest.c -o cyclictest -static
>
> results in
...
> while
>
> gcc -Wall -O2 cyclictest.c -o cyclictest -lrt -lpthread -static
>
> compiles and links fine!
>
> Any idea why the order matters?
The order does always matter. From 'info gcc':
It makes a difference where in the command you write this option;
the linker searches and processes libraries and object files in
the order they are specified. Thus, `foo.o -lz bar.o' searches
library `z' after file `foo.o' but before `bar.o'. If `bar.o'
refers to functions in `z', those functions may not be loaded.
So in your first case, run with -v to see the linker options:
[EMAIL PROTECTED]:~/tmp/cyclictest$ gcc -v -Wall -O2 -lpthread -lrt
cyclictest.c -o cyclictest -static 2>&1 | grep collect2
/usr/lib/gcc/i486-linux-gnu/4.1.2/collect2 -m elf_i386 -static -o
cyclictest /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.1.2/crtbeginT.o
-L/usr/lib/gcc/i486-linux-gnu/4.1.2 -L/usr/lib/gcc/i486-linux-gnu/4.1.2
-L/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -lpthread -lrt /tmp/cc2ooNdo.o --start-group -lgcc
-lgcc_eh -lc --end-group /usr/lib/gcc/i486-linux-gnu/4.1.2/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crtn.o
collect2: ld returned 1 exit status
... crt1.o crti.o crtbeginT.o -lpthread -lrt cc2ooNdo.o crtend.o
Robert
--
Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
Handelsregister: Amtsgericht Hildesheim, HRA 2686
Hannoversche Str. 2, 31134 Hildesheim, Germany
Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9
-
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html