gpt4 book ai didi

C++ cmake & boost & arm 交叉编译

转载 作者:太空狗 更新时间:2023-10-29 23:00:40 54 4
gpt4 key购买 nike

我在使用 boost 和 cmake 编译程序时遇到问题。我使用 gcc-linaro-arm-linux-gnueabihf-4.9/bin/arm-linux-gnueabihf-g++ 编译器进行交叉编译。现在我有如下 cmake 文件:

cmake_minimum_required (VERSION 2.6.2)
project (xxx)

SET(CMAKE_CXX_COMPILER /home/kamil/gcc-linaro-arm-linux-gnueabihf-4.9/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -Dtypeof=__typeof__ -D_GLIBCXX_USE_CXX11_ABI=0 -Wall -Werror -Wextra -Wno-error=array-bounds")

if(DEFINED ENV{SDKTARGETSYSROOT})
set(CMAKE_FIND_ROOT_PATH $ENV{SDKTARGETSYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endif(DEFINED ENV{SDKTARGETSYSROOT})

find_package(Boost COMPONENTS system filesystem REQUIRED)

include_directories("/usr/local/include")
include_directories(${Boost_INCLUDE_DIRS})

enable_testing()
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} )

add_subdirectory(src)
add_subdirectory(test EXCLUDE_FROM_ALL)

add_executable(xxxx
main.cpp
...cpp
...cpp
...cpp
...cpp
)

target_link_libraries(xxxx
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
)

install(TARGETS xxxx
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)

现在在 linux(Ubuntu) 中使用命令时:

  • CMake ..
  • 制作

我有回复:

kamil@kamil:~/test/build$ rm -rf *
kamil@kamil:~/test/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- Found GTest: /usr/local/lib/libgtest.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kamil/test/build
kamil@kamil:~/test/build$ make
Scanning dependencies of target xxxx
[ 12%] Building CXX object src/CMakeFiles/test.dir/main.cpp.o
In file included from /home/test/src/test/utils/logger.hpp:4:0,
from /home/kamil/test/src/main.cpp:9:
/home/kamil/test/src/test/utils/singleton.hpp:5:33: fatal error: boost/noncopyable.hpp: No such file or directory
#include <boost/noncopyable.hpp>
^
compilation terminated.
make[2]: *** [src/CMakeFiles/test.dir/main.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2

错误:

fatal error: boost/noncopyable.hpp: No such file or directory
#include <boost/noncopyable.hpp>

当我在 cmake 中评论以下行时:

SET(CMAKE_CXX_COMPILER /home/kamil/toradex/gcc-linaro-arm-linux-gnueabihf-4.9/bin/arm-linux-gnueabihf-g++)

那么一切就OK了。

我在 Ubuntu 中使用命令安装 boost:sudo apt-get install libboost1.55-all-dev

使用 linux-gnueabihf-g++ 编译有什么问题以及如何修复它。

最佳答案

使用 gcc-linaro-arm-linux-gnueabihf-4.9 编译 boost 有效。帮助链接:http://www.cnx-software.com/2011/10/03/cross-compiling-boost-c-libraries-for-arm/

关于C++ cmake & boost & arm 交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33180585/

54 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com