[CMake] Strange problem creating and linking against a static lib

Joachim Ziegler ziegler at mpi-sb.mpg.de
Tue Jan 6 05:00:17 EST 2009


Hello list,

I've tried to put all my .o-files into some kind of "convenience lib" so
that not every object file is rebuilt for every target that I have. A
problem arises when I try to create a static lib and a static
binary that is linked against this lib.

I have in my CMakeLists.txt (here only excerpts from it):

# list of all .cpp and .h files
SET(BASEFILES ${BASEHEADERS} ${BASESOURCEFILES})

ADD_LIBRARY(baselib STATIC ${BASEFILES})

ADD_EXECUTABLE(startCompletionServer StartCompletionServer.cpp)

TARGET_LINK_LIBRARIES(startCompletionServer baselib pthread z -static)

Now when I compile and try to run:

Linking CXX static library libbaselib.a
[ 85%] Built target baselib
Linking CXX executable startCompletionServer
[100%] Built target startCompletionServer

$ ./startCompletionServer
-bash: ./startCompletionServer: No such file or directory

$ ll ./startCompletionServer
-rwxr-xr-x 1 ziegler Mehlhorn 2896216 Jan  6 10:54 ./startCompletionServer

$ ldd ./startCompletionServer
/usr/bin/X11/ldd: line 117: ./startCompletionServer: No such file or
directory

What is this? The file is there and is NOT there???

I'm new to CMake, forgive me. What's the correct way to create static
binaries with CMake?

How would I construct a switch that lets me chose whether I want to
create dynamic or static libs and binaries?

Thank you in advance,
Joachim


PS: My system is

$ uname -a
Linux twit 2.6.24.2.1.amd64-smp #1 SMP Mon Feb 11 12:43:21 UTC 2008
x86_64 GNU/Linux
$ cmake --version
cmake version 2.4-patch 8





More information about the CMake mailing list