学习cmake-cookbook/chapter-02/recipe-06/cxx-example

在Ubuntu系统中,使用cmake构建项目时遇到找不到Eigen3库的错误。通过运行`sudoapt-add-repositoryuniverse`和`sudoapt-getinstalllibeigen3-dev`安装缺失的开发包后,cmake配置成功,编译问题得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cmake编译时报找不到“Eigen3”错误:

root@kirinai-15-g5000pro:/workspace/cmake/cmake-cookbook/chapter-02/recipe-06/cxx-example# cmake .
-- The CXX compiler identification is GNU 7.5.0
-- 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
CMake Error at CMakeLists.txt:9 (find_package):
  Could not find a package configuration file provided by "Eigen3" (requested
  version 3.3) with any of the following names:

    Eigen3Config.cmake
    eigen3-config.cmake

  Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
  "Eigen3_DIR" to a directory containing one of the above files.  If "Eigen3"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/workspace/cmake/cmake-cookbook/chapter-02/recipe-06/cxx-example/CMakeFiles/CMakeOutput.log".

首先通过以下方式暗转Eigen3的开发包:        

sudo apt-add-repository universe
sudo apt-get install libeigen3-dev

然后再重试就可以了。

root@kirinai-15-g5000pro:/workspace/cmake/cmake-cookbook/chapter-02/recipe-06/cxx-example# cmake .
-- The CXX compiler identification is GNU 7.5.0
-- 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
-- Performing Test _march_native_works
-- Performing Test _march_native_works - Success
-- Performing Test _xhost_works
-- Performing Test _xhost_works - Failed
-- Using processor's vector instructions (-march=native compiler flag set)
-- Configuring done
-- Generating done
-- Build files have been written to: /workspace/cmake/cmake-cookbook/chapter-02/recipe-06/cxx-example

详细参见:

cmake 找不到 eigen3 包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值