【问题标题】:Cmake build failed with CMAKE_AR-NOTFOUND (cr exe not found)Cmake 构建因 CMAKE_AR-NOTFOUND 失败(找不到 cr exe)
【发布时间】:2017-03-05 18:06:18
【问题描述】:

cmake 构建失败

CMAKE_AR-NOTFOUND cr libperfutils.a

当我检查构建文件夹 ar 未设置时。 x86_64-linux\gtest-native\1.7.0-r5\build\CMakeCache.txt

CMAKE_AR:FILEPATH=CMAKE_AR-NOTFOUND

//CXX compiler.
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++

如何在cmake中设置ar?

当我看到输出下方的 cmake 配置时。 cmake 自动查找 g++ 以及为什么它没有检测到 ar

-- The CXX compiler identification is GNU 4.8.4
-- Check for working CXX compiler: g++
-- Check for working CXX compiler: g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done

当我手动检查机器时,它可用。

/usr/bin/ar

【问题讨论】:

  • 你使用什么 CMake 版本?你想交叉编译吗?无论如何,CMakeLists.txt 的内容(minimal reproducible example 的形式)会有所帮助。
  • cmake-2.8.12.2 为 x86_64 GNU/Linux 构建

标签: c++ makefile cmake linux-toolchain


【解决方案1】:

CMake 本身应该能够检测到 /usr/bin/ar,但您可以使用 -D CMAKE_AR=/usr/bin/ar 选项手动覆盖它。

以下是有用变量的列表:

https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables

【讨论】:

    【解决方案2】:

    cmake ar 应该在 cmake lib build 中设置, 通过在我的本地 Cmake 文件中手动设置临时解决了这个问题

    set( CMAKE_AR "${AR}" CACHE FILEPATH "Archiver" )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      • 2016-01-14
      • 2016-08-01
      • 2015-12-08
      • 1970-01-01
      • 2021-12-15
      相关资源
      最近更新 更多