使用CMake进行交叉编译

时间:2015-02-26 21:44:54

标签: c++ linux linker cmake

这是我的CMakeLists.txt

它会导致错误消息“找不到/usr/lib/libpthread_nonshared.a”。 这似乎是错误的路径,因为不评估前缀CMAKE_FIND_ROOT_PATH。 为什么哎?

提前致谢。

编辑:查找库提供正确的路径! /home/micha/projects/Raspberry/rootfs/usr/lib/libpthread.so

cmake_minimum_required(VERSION 2.8)
SET(CMAKE_SYSTEM_NAME Linux)
INCLUDE(CMakeForceCompiler)
SET(CMAKE_C_COMPILER /home/micha/ExtPackSrcs/CrossCompilerPi/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi-cc)
SET(CMAKE_CXX_COMPILER /home/micha/ExtPackSrcs/CrossCompilerPi/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi-c++)

SET(CMAKE_FIND_ROOT_PATH /home/micha/projects/Raspberry/rootfs)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

project(arrg)

find_library(LIB_PTHREAD pthread)
message("LIB_PTHREAD " ${LIB_PTHREAD})

add_executable(arrg
      main.cpp
      )

target_link_libraries(arrg
  ${LIB_PTHREAD}
)

0 个答案:

没有答案