【发布时间】:2021-12-01 22:40:01
【问题描述】:
我很想解决这个问题。我多年来一直使用 cmake (3.18.2) 和 Xcode,但它突然停止工作。进行以下简单设置:
我制作了一个main.cpp 文件:
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
还有以下 CMakeLists.txt 文件:
cmake_minimum_required(VERSION 3.14)
project(untitled)
add_executable(untitled main.cpp)
我制作了一个构建文件并在其中运行:
$ cmake ..
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang - broken
CMake Error at /opt/anaconda3/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/local/bin/gmake cmTC_95f1f/fast && /usr/local/bin/gmake -f CMakeFiles/cmTC_95f1f.dir/build.make CMakeFiles/cmTC_95f1f.dir/build
gmake[1]: Entering directory '/Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_95f1f.dir/testCCompiler.c.o
/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/anaconda3/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -o CMakeFiles/cmTC_95f1f.dir/testCCompiler.c.o -c /Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_95f1f
/opt/anaconda3/bin/cmake -E cmake_link_script CMakeFiles/cmTC_95f1f.dir/link.txt --verbose=1
/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/anaconda3/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/opt/anaconda3/lib -L/opt/anaconda3/lib CMakeFiles/cmTC_95f1f.dir/testCCompiler.c.o -o cmTC_95f1f
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_95f1f.dir/build.make:106: cmTC_95f1f] Error 1
gmake[1]: Leaving directory '/Users/bmetcalf/Test/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_95f1f/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/Users/bmetcalf/Test/build/CMakeFiles/CMakeOutput.log".
See also "/Users/bmetcalf/Test/build/CMakeFiles/CMakeError.log".
使用的 cmake 来自 anaconda,但自制 cmake 也会发生这种情况。两者都是最新的。
我已经安装了最新的 Xcode 和命令行工具 (v13.0),因为这开始于无法构建 Xcode 项目,但这似乎与
Xcode。我尝试使用xcode-select --reset、xcode-select -s /Applications/Xcode.app/Contents/Developer/、xcode-select -s /Library/Developer/CommandLineTools 等重置 Xcode 路径。这些都没有帮助。我已经在 Xcode 首选项->位置中设置了命令行工具。
【问题讨论】:
-
这有帮助吗? stackoverflow.com/questions/63592445/… 作为建议,请始终查看 cmake 输出的内容,因为它非常有用。总是尝试运行它尝试过的命令,看看你得到了什么,然后尝试调整这些命令以解决你的问题
-
也许这里的解决方案有帮助:stackoverflow.com/questions/63592445/…
-
我遵循了 stackoverflow.com/questions/63592445/... 中的解决方案,包括重新启动计算机。没有变化。我已经查看了 cmake 输出,但我无法理解它。我不明白为什么 cmake 不能使用本地 clang 而不是 anaconda 版本。测试编译某些测试程序似乎有错误。
-
anaconda 的 cmake 似乎不再兼容 Xcode。它使用来自 cmake 发行版的编译器,这些编译器似乎不适用于测试文件。
-
正好是condo-cmake-xcode问题link