[CMake] Strange problem creating and linking against a static lib
Joachim Ziegler
ziegler at mpi-sb.mpg.de
Wed Jan 7 09:12:32 EST 2009
Joachim Ziegler wrote:
> I suppose the problem is in the link line, which says:
>
> /usr/bin/X11/c++ -fPIC -static
> "CMakeFiles/startCompletionServer.dir/StartCompletionServer.o" -o
> startCompletionServer -rdynamic -L/KM/home-0/ziegler/tmp/build
> -Wl,-Bstatic -lbaselib -Wl,-Bdynamic -lpthread -lz
> -Wl,-rpath,/KM/home-0/ziegler/tmp/build
Yes it is. If I replace the above "-Wl,-Bdynamic -lpthread -lz" by an
explicit
-Wl,-Bstatic -lpthread -lz
the problem vanishes.
With the original link line issued by CMake as listed above, I have a
reference to a non.existing library in my binary file:
$ xxd startCompletionServer | head -n 25
0000000: 7f45 4c46 0101 0100 0000 0000 0000 0000 .ELF............
0000010: 0200 0300 0100 0000 c0b7 0408 3400 0000 ............4...
0000020: 5482 8800 0000 0000 3400 2000 0700 2800 T.......4. ...(.
0000030: 2600 2300 0600 0000 3400 0000 3480 0408 &.#.....4...4...
0000040: 3480 0408 e000 0000 e000 0000 0500 0000 4...............
0000050: 0400 0000 0300 0000 1401 0000 1481 0408 ................
0000060: 1481 0408 1300 0000 1300 0000 0400 0000 ................
0000070: 0100 0000 0100 0000 0000 0000 0080 0408 ................
0000080: 0080 0408 eae3 2500 eae3 2500 0500 0000 ......%...%.....
0000090: 0010 0000 0100 0000 ece3 2500 ec73 2a08 ..........%..s*.
00000a0: ec73 2a08 0405 0000 b811 0000 0600 0000 .s*.............
00000b0: 0010 0000 0200 0000 58e4 2500 5874 2a08 ........X.%.Xt*.
00000c0: 5874 2a08 f000 0000 f000 0000 0600 0000 Xt*.............
00000d0: 0400 0000 0400 0000 2801 0000 2881 0408 ........(...(...
00000e0: 2881 0408 2000 0000 2000 0000 0400 0000 (... ... .......
00000f0: 0400 0000 51e5 7464 0000 0000 0000 0000 ....Q.td........
0000100: 0000 0000 0000 0000 0000 0000 0600 0000 ................
0000110: 0400 0000 2f75 7372 2f6c 6962 2f6c 6962 ..../usr/lib/lib
0000120: 632e 736f 2e31 0000 0400 0000 1000 0000 c.so.1..........
0000130: 0100 0000 474e 5500 0000 0000 0200 0000 ....GNU.........
0000140: 0400 0000 0100 0000 c500 0000 cb00 0000 ................
There is no /usr/lib/libc.so.1 on my system, and anyway there should be
no reference in the binary to a dynamic lib.
So what can I do to tell CMake to link everything statically?
Thanks and kind regards,
Joachim Ziegler
More information about the CMake
mailing list