Hummingbird_Joe 2023-09-22 03:59 采纳率: 81.8%
浏览 194

Ubuntu18.04安装ceres-solver时发生的编译问题

我尝试在实验室的Linux服务器上安装ceres-solver(https://github.com/ceres-solver/ceres-solver),因为我没有root权限,所以尝试下载Zip文件并解压缩后使用CMake进行构建。但是在执行make install时出现了问题。

下面是我的所有 Linux 命令。

tar -zxf ceres-solver-2.0.0.tar.gz
cd ceres-solver-2.0.0/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/home/zhangzb/include/Ceres/ -DCMAKE_PREFIX_PATH=/home/zhangzb/include/Glog -DCMAKE_PREFIX_PATH=/home/zhangzb/include/eigen3/ -DCMAKE_PREFIX_PATH=/home/zhangzb/include/Gflags/ -Dglog_DIR=/home/zhangzb/include/Glog  ..
make install

在执行cmake命令后,一切都正常进行。但在执行make install命令后,出现了以下问题

make[2]: *** No rule to make target '/tmp/build/80754af9/snappy_1649923748780/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib/librt.so', needed by 'bin/small_blas_gemv_benchmark'.  Stop.
CMakeFiles/Makefile2:3192: recipe for target 'internal/ceres/CMakeFiles/small_blas_gemv_benchmark.dir/all' failed
make[1]: *** [internal/ceres/CMakeFiles/small_blas_gemv_benchmark.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2

我注意到它试图在/tmp/build/80754af9/snappy_1649923748780/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib/librt.so中查找librt.so,但librt.so位于/usr/lib/x86_64-linux-gnu/中。

zhangzb@master:~/include/ceres-solver-2.0.0/build$ ls -l /usr/lib/x86_64-linux-gnu/librt.so
lrwxrwxrwx 1 root root 32 5 3 2022 /usr/lib/x86_64-linux-gnu/librt.so -> /lib/x86_64-linux-gnu/librt.so.

我希望它可以在正确的位置(/usr/lib/x86_64-linux-gnu/librt.so)找到librt.so,这样我就可以成功安装Ceres Solver。

  • 写回答

3条回答 默认 最新

  • 专家-赤兔[在线] 全栈领域优质创作者 2023-09-22 04:26
    关注

    引用 皆我百晓生 小程序回复内容作答:
    这个问题可能是因为CMake在查找依赖库时使用了错误的路径。你可以尝试以下解决方法:

    1. 在运行cmake之前,先将当前路径(build目录)添加到LD_LIBRARY_PATH环境变量中,命令如下:
      export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH

    2. 修改你的cmake命令,将默认的库路径更改为正确的路径(/usr/lib/x86_64-linux-gnu/),例如:
      cmake -DCMAKE_INSTALL_PREFIX=/home/zhangzb/include/Ceres/ -DCMAKE_PREFIX_PATH=/home/zhangzb/include/Glog -DCMAKE_PREFIX_PATH=/home/zhangzb/include/eigen3/ -DCMAKE_PREFIX_PATH=/home/zhangzb/include/Gflags/ -Dglog_DIR=/home/zhangzb/include/Glog -DLIBRARY_OUTPUT_PATH=/usr/lib/x86_64-linux-gnu/ ..

    3. 如果以上方法仍然无效,你可以尝试手动将librt.so链接到/tmp/build/80754af9/snappy_1649923748780/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib/目录中,命令如下:
      ln -s /usr/lib/x86_64-linux-gnu/librt.so /tmp/build/80754af9/snappy_1649923748780/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib/

    尝试以上解决方法后,重新执行make install命令,看看问题是否解决。如果仍然存在问题,请检查其他依赖库的路径是否正确,并进行类似的修复操作。希望这些方法对你有帮助!

    评论
  • CSDN-Ada助手 CSDN-AI 官方账号 2023-09-22 06:21
    关注

    【相关推荐】



    • 这篇博客: Ceres-Solver 安装与卸载ubuntu20.04中的  1、cmake 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:

      cmake时的日志

      (base) r****@r*******:~/3dTracking/tools/ceres-solver-1.14.0$ sudo apt-get install libgtest-dev
      Reading package lists... Done
      Building dependency tree       
      Reading state information... Done
      libgtest-dev is already the newest version (1.10.0-2).
      (base) r****@r*******:~/3dTracking/tools/ceres-solver-1.14.0/build$ cmake ..
      -- The C compiler identification is GNU 7.5.0
      -- The CXX compiler identification is GNU 7.5.0
      -- Check for working C compiler: /usr/bin/cc
      -- Check for working C compiler: /usr/bin/cc -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Check for working CXX compiler: /usr/bin/c++
      -- Check for working CXX compiler: /usr/bin/c++ -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Detected Ceres version: 1.14.0 from /home/r****/3dTracking/tools/ceres-solver-1.14.0/include/ceres/version.h
      -- No preference for use of exported Eigen CMake configuration set, and no hints for include directory provided. Defaulting to preferring an installed/exported Eigen CMake configuration if available.
      -- Found installed version of Eigen: /usr/local/share/eigen3/cmake
      -- Found Eigen: /usr/local/include/eigen3 (found version "3.3.90") 
      -- Found Eigen version 3.3.90: /usr/local/include/eigen3
      -- Enabling use of Eigen as a sparse linear algebra library.
      -- Looking for sgemm_
      -- Looking for sgemm_ - not found
      -- Looking for pthread.h
      -- Looking for pthread.h - found
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
      -- Looking for pthread_create in pthreads
      -- Looking for pthread_create in pthreads - not found
      -- Looking for pthread_create in pthread
      -- Looking for pthread_create in pthread - found
      -- Found Threads: TRUE  
      -- Looking for dgemm_
      -- Looking for dgemm_ - found
      -- Found BLAS: /usr/lib/x86_64-linux-gnu/libf77blas.so;/usr/lib/x86_64-linux-gnu/libatlas.so  
      -- Found LAPACK library: /usr/lib/x86_64-linux-gnu/liblapack.so;/usr/lib/x86_64-linux-gnu/libf77blas.so;/usr/lib/x86_64-linux-gnu/libatlas.so
      -- Found AMD headers in: /usr/include/suitesparse
      -- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
      -- Found CAMD headers in: /usr/include/suitesparse
      -- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
      -- Found COLAMD headers in: /usr/include/suitesparse
      -- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
      -- Found CCOLAMD headers in: /usr/include/suitesparse
      -- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
      -- Found CHOLMOD headers in: /usr/include/suitesparse
      -- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
      -- Found SUITESPARSEQR headers in: /usr/include/suitesparse
      -- Found SUITESPARSEQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
      -- Did not find Intel TBB library, assuming SuiteSparseQR was not compiled with TBB.
      -- Found SUITESPARSE_CONFIG headers in: /usr/include/suitesparse
      -- Found SUITESPARSE_CONFIG library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
      -- Found LIBRT library: /usr/lib/x86_64-linux-gnu/librt.so
      -- Adding librt: /usr/lib/x86_64-linux-gnu/librt.so to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
      -- Found METIS library: /usr/lib/x86_64-linux-gnu/libmetis.so
      -- Found SuiteSparse: TRUE (found version "5.7.1") 
      -- Found SuiteSparse 5.7.1, building with SuiteSparse.
      -- Found CXSparse: /usr/include/suitesparse (found version "3.2.0") 
      -- Found CXSparse version: 3.2.0, building with CXSparse.
      -- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
      -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
      -- Detected gflags version: 2.2.2
      -- Found Gflags: /usr/include  
      -- Found Google Flags header in: /usr/include, in namespace: google
      -- No preference for use of exported glog CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported glog CMake configuration if available.
      -- Found installed version of glog: /usr/local/lib/cmake/glog
      -- Detected glog version: 0.6.0
      -- Found Glog: glog::glog  
      -- Found Google Log (glog). Assuming glog was built with gflags support as gflags was found. This will make gflags a public dependency of Ceres.
      -- Building with OpenMP.
      -- Performing Test COMPILER_HAS_CXX11_FLAG
      -- Performing Test COMPILER_HAS_CXX11_FLAG - Success
      -- Looking for C++ include unordered_map
      -- Looking for C++ include unordered_map - found
      -- Performing Test HAVE_UNORDERED_MAP_IN_STD_NAMESPACE
      -- Performing Test HAVE_UNORDERED_MAP_IN_STD_NAMESPACE - Success
      -- Found unordered_map/set in std namespace.
      -- Looking for C++ include memory
      -- Looking for C++ include memory - found
      -- Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE
      -- Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE - Success
      -- Found shared_ptr in std namespace using <memory> header.
      -- Performing Test CXX11_MATH_FUNCTIONS_FOUND
      -- Performing Test CXX11_MATH_FUNCTIONS_FOUND - Success
      -- Building Ceres as a static library.
      -- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.
      -- Creating configured Ceres config.h output directory: /home/r****/3dTracking/tools/ceres-solver-1.14.0/build/config/ceres/internal
      -- Enabling CERES_USE_EIGEN_SPARSE in Ceres config.h
      -- Enabling CERES_USE_OPENMP in Ceres config.h
      -- Enabling CERES_HAVE_PTHREAD in Ceres config.h
      -- Enabling CERES_HAVE_RWLOCK in Ceres config.h
      -- Enabling CERES_STD_UNORDERED_MAP in Ceres config.h
      -- Build the examples.
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /home/r****/3dTracking/tools/ceres-solver-1.14.0/build

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^

    展开全部

    评论
  • IT工程师_二师兄 2023-09-22 08:04
    关注

    你把报错复制出来还有运行记录都发给我

    评论
编辑
预览

报告相同问题?

问题事件

  • 修改了问题 9月22日
  • 创建了问题 9月22日
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部