gpt4 book ai didi

c++ - CMake交叉编译

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:52:31 25 4
gpt4 key购买 nike

我的 cmake 交叉编译器项目有问题。

我的交叉编译器没有找到使用过的库。我使用本教程设置我的交叉编译器 Cross Compiler .

现在我需要将它们安装在我的 RaspberryPi 上的库。我已将我的/lib 和/usr 目录从 Pi 同步到/opt/cross/rasp 中的计算机。这是我的工具链文件:

# 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 的误解有关,请参阅 fixing-rpath-link-issues-with-cross-compilers

为了添加缺少的 rpath-link,您可以附加到工具链 cmake 文件:

SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath-link=/opt/cross/rasp/lib/arm-linux-gnueabihf:/opt/cross/rasp/usr/lib/arm-linux-gnueabihf")

关于c++ - CMake交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29868060/

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