2017-06-22 206 views
0

對於我的節目,我想用一些Boost庫,但是當我做節目,我得到的錯誤:cmake的交叉編譯升壓鏈接錯誤

/home/ubunturik/rpinew/rootfs/usr/lib/arm-linux-gnueabihf/libboost_regex.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20' 
/home/ubunturik/rpinew/rootfs/usr/lib/arm-linux-gnueabihf/libicuuc.so.52: undefined reference to `[email protected]_1.3.8' 
collect2: error: ld returned 1 exit st 

我跟着這個教程http://amgaera.github.io/blog/2014/04/10/cross-compiling-for-raspberry-pi-on-64-bit-linux/。爲了獲得提升,我使用了在樹莓派上安裝libboost-all-dev並使用這些文件。

CMake的文件:

cmake_minimum_required(VERSION 3.5) 
SET(CMAKE_SYSTEM_NAME Linux) 
SET(CMAKE_SYSTEM_VERSION 1) 

# Specify the cross compiler 
SET(CMAKE_C_COMPILER $ENV{HOME}/rpinew/toolchain/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc) 
SET(CMAKE_CXX_COMPILER $ENV{HOME}/rpinew/toolchain/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++) 

# Where is the target environment 
SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/rpinew/rootfs) 
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}") 
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}") 
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}") 

# Search for programs only in the build host directories 
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 

# Search for libraries and headers only in the target directories 
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 

#for boost 
set(Boost_INCLUDE_DIR /home/ubunturik/rpinew/rootfs/usr/include) 
set(Boost_LIBRARY_DIR /home/ubunturik/rpinew/rootfs/usr/lib/arm-linux-gnueabihf) 
find_package(Boost COMPONENTS regex date_time system chrono filesystem program_options thread REQUIRED) 
include_directories(${Boost_INCLUDE_DIR}) 
link_directories(${Boost_LIBRARY_DIR}) 

#Bring the headers, such as Student.h into the project 
include_directories(include) 

include_directories($ENV{HOME}/rpinew/rootfs/usr/include/arm-linux-gnueabihf) 

#However, the file(GLOB...) allows for wildcard additions: 
file(GLOB SOURCES "src/*.cpp") 

add_executable(MonitorApp ${SOURCES}) 
target_link_libraries(MonitorApp ${PROJECT_LINK_LIBS} ${Boost_LIBRARIES}) 

如何解決這個問題?

回答

1

您正在進行交叉編譯,因此您安裝了特定的工具鏈(編譯器,庫等)。然後,您嘗試使用通常的boost庫,這些庫是使用普通編譯器構建的,並且依賴於普通的庫。失敗並不令人驚訝,是嗎?

我不知道是否有一種簡單的方法,但是使用您的編譯器和用於Raspberry Pi的庫編譯來自源代碼的boost應該可以做到。