我迫切地想解决这个问题。我已经使用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 preference->位置设置了命令行工具。
1条答案
按热度按时间mnemlml81#
这是Anaconda重置环境变量的结果,以便使用自己的构建工具,而不是Xcode命令行工具中的工具。这些与使用Anaconda提供的cmake构建Xcode项目兼容,但现在不再是这样了。你甚至不能让另一个源代码的cmake工作,因为Anaconda也会强制它使用Anaconda的工具。很难重置所有必要的环境变量,或者使Anaconda以更持久的方式与macOS 10.9 SDK或更高版本(请参阅链接)兼容。也许使用Conda环境可以以某种方式避免对系统的干扰。对我来说,anaconda干扰你构建自己的程序违背了它的目的。