cmake 交叉编译 link 提升
cmake crosscompile link boost
我有一个 (YOCTO) SKD,包括用于我的 ARM Target 32 位的提升。主机在 Ubuntu 18.04.
我如何link提升?
正如@Tsyvarev指出的:
首先准备工具链,然后使用链接的 Boost 制作项目。
cmake_minimum_required(VERSION 3.19)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
# sysroot
set(CMAKE_SYSROOT /opt/karo-base/1.0/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
# compiler
set(TOOLCHAIN_PREFIX /opt/karo-base/1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(COMPILER_FLAGS " -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -mbe32")
set(CMAKE_C_FLAGS "${COMPILER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${COMPILER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
project(helloBoost )
# see https://cmake.org/cmake/help/v3.5/module/FindBoost.html
find_package(Boost REQUIRED COMPONENTS ALL)
add_executable(helloBoost main.cpp)
target_link_libraries(helloBoost Boost::boost Boost::log)
我有一个 (YOCTO) SKD,包括用于我的 ARM Target 32 位的提升。主机在 Ubuntu 18.04.
我如何link提升?
正如@Tsyvarev指出的:
首先准备工具链,然后使用链接的 Boost 制作项目。
cmake_minimum_required(VERSION 3.19)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
# sysroot
set(CMAKE_SYSROOT /opt/karo-base/1.0/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
# compiler
set(TOOLCHAIN_PREFIX /opt/karo-base/1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(COMPILER_FLAGS " -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -mbe32")
set(CMAKE_C_FLAGS "${COMPILER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${COMPILER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
project(helloBoost )
# see https://cmake.org/cmake/help/v3.5/module/FindBoost.html
find_package(Boost REQUIRED COMPONENTS ALL)
add_executable(helloBoost main.cpp)
target_link_libraries(helloBoost Boost::boost Boost::log)