I am having strange problems with my cmake cross compiler projects.
My own libraries were found, but not (system) libraries from my toolchain.
I used to use KDevelop on a debian squeeze machine. now on my new debian wheezy machine the setup failed. It does not find system libraries such as m or pthread .
It worked perfectly on my old machine, but I donβt remember that I did anything special to make this work.
Here is one of my CMakeLists.txt files
cmake_minimum_required(VERSION 2.8) SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_VERSION 2.6.36.4) SET(CMAKE_C_COMPILER arm-angstrom-linux-gnueabi-gcc) SET(CMAKE_CXX_COMPILER arm-angstrom-linux-gnueabi-g++) include_directories(../include ../../../sample/include) project(testmain) add_executable(testmain some_c-source-file.c) set(CMAKE_LIBRARY_PATH ../lib/arm-26/lib ../../../sample/lib/arm-26/lib) find_library(LIBS_TEST NAMES akku) find_library(LIBS_M NAMES m) find_library(LIBS_PTHREAD NAMES pthread ) target_link_libraries(akkumain ${LIBS_TEST} ${LIBS_M} ${LIBS_PTHREAD}) set(CMAKE_C_FLAGS "-Wall -Werror") set(CMAKE_C_FLAGS_DEBUG "-g3 -O2 -rdynamic") set(CMAKE_C_FLAGS_RELEASE "-g0 -O0") set(CMAKE_CXX_FLAGS "-Wall -Werror") set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O2 -rdynamic") set(CMAKE_CXX_FLAGS_RELEASE "-g0 -O0")
This message is displayed when I try to compile with KDevelop: (to repeat it myself: it worked on my old machine)
/home/user/testmain/build> /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug /home/user/testmain/ -- The C compiler identification is GNU 4.3.3 -- The CXX compiler identification is GNU 4.3.3 -- Check for working C compiler: /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-gcc -- Check for working C compiler: /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++ -- Check for working CXX compiler: /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: LIBS_M linked by target "akkumain" in directory /home/user/testmain LIBS_PTHREAD linked by target "akkumain" in directory /home/user/testmain
So found LIBS_TEST. But not libm or libpthread . I tried this with different projects: all my libraries were found, but not one of the "system" libraries.
I already tried different things, for example
set(CMAKE_FIND_LIBRARY_PREFIXES lib ) set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
and something else that I donβt remember.
The only thing WORKS when I specify the directory manually:
find_library(ASTLIBS_M NAMES m PATHS /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib)
After pointing this to my CMakeLists.txt a library is found, and I can compile my project without any errors.
BUT: This is not what I want, because I have many projects and many libraries, and I do not want to edit all my CMakeLists.txt ... CMakeLists.txt
Does anyone know what made my old machine find system libs without specifying anything special inside my IDE / CMake files?
Edit: I just noticed for one of my executables that at the Linker stage it throws some errors that some characters from glibc cannot find - it seems that something is wrong with my debian wheezy system. - I hope I can understand this ...
Edit:
Maybe I should give a brief summary: My code compiles well, but all the libraries from my tool chain are not found, but if I add the path to the libraries of my tool chain manually, it compiles, but does not work at the linker stage.