【问题标题】:Building using CMake within Conda environment在 Conda 环境中使用 CMake 构建
【发布时间】:2019-01-30 04:44:56
【问题描述】:

我有一台资源受限的实验室机器(不受我控制),它基本上只允许我写入外部硬盘。

我需要使用 boost 和 pcl 编译我的类项目。我的程序是在外部硬盘中创建一个 conda 环境,然后是conda install -c conda-forge boost pcl

就安装软件包而言,这是可行的。当我需要编译时,我使用以下 CMake 工具链文件:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

SET(CMAKE_C_COMPILER   /XXX/bin/clang)
SET(CMAKE_CXX_COMPILER /XXX/bin/clang++)

SET(CMAKE_FIND_ROOT_PATH  /YYY/conda/envs/thesis-env /XXX/llvm)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

这可以在运行 cmake 和 make 时完成编译工作。当您尝试链接时,问题就开始了;我明白了:

/usr/bin/ld: warning: libboost_system.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_filesystem.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_thread.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_date_time.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_iostreams.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_chrono.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_atomic.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_regex.so.1.66.0, needed by /media/libre/jbayardo/conda/envs/thesis-env/lib/libpcl_common.so, not found (try using -rpath or -rpath-link)
CMakeFiles/nch.dir/main.cpp.o: En la función `boost::system::generic_category()':
main.cpp:(.text._ZN5boost6system16generic_categoryEv[_ZN5boost6system16generic_categoryEv]+0x6): referencia a `boost::system::detail::generic_category_instance' sin definir

我的理解是 pcl 的 boost 依赖在链接期间没有得到正确解决。有什么办法可以帮助 CMake 解决这个问题?

【问题讨论】:

    标签: boost cmake linker anaconda conda


    【解决方案1】:

    您需要按照它所说的去做:将-rpath-link=<directory-containing-boost-libs> 添加到链接行。您还可以使用 patchelf 之类的方式在 libpcl_common.so 中添加相同的目录作为 RPATH 条目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-02
      • 2018-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-03
      • 1970-01-01
      • 2017-04-02
      相关资源
      最近更新 更多