找不到CMAKE交叉编译库
发布时间:2020-12-14 01:35:22 所属栏目:Linux 来源:网络整理
导读:我的cmake交叉编译器项目遇到了奇怪的问题. 我找到了自己的库,但没有找到我工具链中的(系统)库. 以前我在debian挤压机上使用KDevelop. 现在我的新机器与debian wheezy配置失败. 它找不到像m或pthread这样的系统库. 在我的旧机器上,以下工作完美,但我不记得我
我的cmake交叉编译器项目遇到了奇怪的问题.
我找到了自己的库,但没有找到我工具链中的(系统)库. 以前我在debian挤压机上使用KDevelop. 在我的旧机器上,以下工作完美,但我不记得我做了一些特别的工作. 这是我的一个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 …… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |