我的 cmake 交叉编译器项目遇到了奇怪的问题。
找到了我自己的库,但没有找到我的工具链中的(系统)库。
以前我在 debian 挤压机上使用 KDevelop。现在在我的带有 debian wheezy 的新机器上配置失败。它找不到像m
或之类的系统库pthread
。
在我的旧机器上,以下工作完美无缺,但我不记得我做了什么特别的事情来完成这项工作。
这是我的一个CMakeLists.txt
文件
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")
这是尝试使用 KDevelop 编译时显示的消息:(重复我自己:这是在我的旧机器上工作)
/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
所以找到了 LIBS_TEST。但不是libm
或libpthread
。我对不同的项目进行了尝试:找到了我的所有库,但没有找到“系统”库。
我已经尝试过不同的东西,比如
set(CMAKE_FIND_LIBRARY_PREFIXES lib )
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
还有一些我不记得的事情。
唯一有效的是当我手动指定目录时:
find_library(ASTLIBS_M NAMES m PATHS /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib)
将其指定给我CMakeLists.txt
的库后,我可以编译我的项目而不会出现任何错误。
但是:这不是我想要的,因为我有很多项目和很多库,我不想编辑我所有的CMakeLists.txt
...... :(
有谁知道是什么让我的旧机器在没有在我的 IDE/CMake 文件中指定任何特殊内容的情况下找到了系统库?
编辑: 我刚刚注意到我的一个可执行文件在 Linker 阶段它抛出了一些错误,它无法从 glibc 中找到一些符号 - 似乎我的 debian wheezy 系统有更多问题。- 我希望我能弄清楚...
编辑: