C++ 交叉编译
我的cmake交叉编译器项目有问题 我的交叉编译器没有找到使用过的库。我用本教程设置了交叉编译器 现在我需要libs,它们安装在我的RaspberryPi上。我已在/opt/cross/rasp中将我的/lib和/usr目录从Pi同步到我的计算机。这是我的工具链文件:C++ 交叉编译,c++,linux,cmake,raspberry-pi,cross-compiling,C++,Linux,Cmake,Raspberry Pi,Cross Compiling,我的cmake交叉编译器项目有问题 我的交叉编译器没有找到使用过的库。我用本教程设置了交叉编译器 现在我需要libs,它们安装在我的RaspberryPi上。我已在/opt/cross/rasp中将我的/lib和/usr目录从Pi同步到我的计算机。这是我的工具链文件: # this one is important SET(CMAKE_SYSTEM_NAME Linux) #this one not so much SET(CMAKE_SYSTEM_VERSION 1) # specify t
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER
/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER
/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /opt/cross/rasp)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
但当我试图编译我的程序时,我得到了以下链接错误:
/opt/cross/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.9.1/../../../../arm-unknown-linux-gnueabi/bin/ld: warning: libltdl.so.7, needed by /opt/cross/rasp/usr/local/lib/libgphoto2.so, not found (try using -rpath or -rpath-link)
/opt/cross/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.9.1/../../../../arm-unknown-linux-gnueabi/bin/ld: warning: libexif.so.12, needed by /opt/cross/rasp/usr/local/lib/libgphoto2.so, not found (try using -rpath or -rpath-link)
在我的RaspberrPi上编译时没有可能的错误 这个问题似乎与对etc/ld.so.conf的误解有关,请参见 要添加缺少的rpath链接,可以将以下内容附加到工具链cmake文件:
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath-link=/opt/cross/rasp/lib/arm-linux-gnueabihf:/opt/cross/rasp/usr/lib/arm-linux-gnueabihf")