在 Conda 环境中使用 CMake 进行构建

在 Conda 环境中使用 CMake 进行构建

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

我需要使用 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 解决这个问题吗?

相关内容