【发布时间】:2013-07-17 07:04:25
【问题描述】:
我的 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 指定后,找到了库,我可以编译我的项目而不会出现任何错误。
但是:这不是我想要的,因为我有 LOT 的项目和许多库,我不想编辑我所有的 CMakeLists.txt... :(
有没有人知道是什么让我的旧机器找到了系统库而没有在我的 IDE/CMake 文件中指定任何特殊内容?
编辑: 我刚刚注意到我的一个可执行文件在 Linker 阶段抛出了一些错误,它无法从 glibc 中找到一些符号 - 似乎我的 debian wheezy 系统有更多问题。 - 我希望我能弄清楚...
编辑:
也许我应该做一个简短的总结:我的代码编译得很好,但是我的工具链中的所有库都没有找到,但是如果我手动将路径添加到我的工具链的库中,它会编译但在链接器阶段失败。
【问题讨论】:
-
仍然没有解决我的问题。根本不可能从工具链链接库。它们设置为 NOTFOUND。 - 我不知道.. :(
标签: c cmake cross-compiling kdevelop angstrom-linux