即使 CMake 已成功配置并使用 Boost 生成了 makefile,我也无法使用 make 命令为 ARM 处理器生成可执行文件,如下所示。
这是我的配置设置:
1.) 我在这个链接中下载了在 Raspberry Pi 中编译的 boost 库 1.49: http ://www.raspberrypi.org/phpBB3/viewtopic.php?t=8111&p=195468
2.) 文件层次结构如下:
sample-boost
-> boost-stage (Contains the lib, and include directories of the boost taken from number 1)
-> build (Contains the generated files from CMake)
-> CMakeLists.txt
-> main.cpp
注意:ARM 交叉编译器完全正常工作,我已经交叉编译了一个 hello world,并使用 Cygwin 中的 CMake 在 Raspberry Pi 中成功运行它(使用位于 C:/cygwin/arm-pi.toolchain.cmake 的交叉工具链文件) .
主文件
#include <iostream> #include <boost/thread.hpp> int main(){ cout << "Hello" << endl; boost::this_thread::sleep(boost::posix_time::millisec(20)); return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.8) Project(main) SET(Boost_INCLUDE_DIR C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include) SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include") SET(BOOST_ROOT C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage) FIND_PACKAGE(Boost) message("BOOST LIBRARY" ${Boost_LIBRARY_DIRS}) message("Boost LIBRARIES:" ${Boost_LIBRARIES}) IF(Boost_FOUND) message("Boost include directory is found") message("Boost_INCLUDE_DIRS": ${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) add_executable(main main.cpp) target_link_libraries( main ${Boost_LIBRARIES} ) ENDIF(Boost_FOUND)
Boost-stage -> 包含(来自 sample-boost\boost_1_49_0\boost)
-> lib (came from boost_1_49_0(bin-only)\lib
此外,调用 ccmake 。表明没有找到 boost_dir。但是,找到了boost包!
如您所见,它已使用 CMake 成功生成了 makefile,但我无法为其创建可执行文件。我想我在设置提升时错过了一些东西。也许我未能成功链接库?不
message("Boost LIBRARIES:" ${Boost_LIBRARIES})
显示库文件?
补充:我做了你要求的。这是我的新 cmakelists.txt
cmake_minimum_required(VERSION 2.8)
Project(main)
SET(Boost_INCLUDE_DIR C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include")
SET(BOOST_ROOT C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage)
SET(Boost_USE_STATIC_LIBS TRUE)
SET(Boost_DEBUG ON)
#FIND_PACKAGE(Boost)
FIND_PACKAGE(Boost COMPONENTS thread)
message("BOOST LIBRARY: " ${Boost_LIBRARY_DIRS})
message("Boost LIBRARIES: " ${Boost_LIBRARIES})
message("LIBS : " ${LIBS})
IF(Boost_FOUND)
message("Boost include directory is found")
message("Boost_INCLUDE_DIRS: "${Boost_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries( main ${Boost_LIBRARIES} )
ENDIF(Boost_FOUND)
这是输出控制台: