导师给了一个活儿,需要重新拾起 C++,无奈的我把虚拟机重新安装了一下,装上了 VS。但是 Win 的整体风格编程的时候实在难受,于是想到了 Jetbrains,反正有学生邮箱,就用 Clion吧。
下载安装一切正常,跑一个实例程序就开始报错了:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/hujinbo/CLionProjects/CppDemo
-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang -- broken
CMake Error at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/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/hujinbo/CLionProjects/CppDemo/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):/anaconda3/bin/make cmTC_5c75c/fast && /anaconda3/bin/make -f CMakeFiles/cmTC_5c75c.dir/build.make CMakeFiles/cmTC_5c75c.dir/build
make[1]: Entering directory '/Users/hujinbo/CLionProjects/CppDemo/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_5c75c.dir/testCCompiler.c.o
/anaconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.14 -o CMakeFiles/cmTC_5c75c.dir/testCCompiler.c.o -c /Users/hujinbo/CLionProjects/CppDemo/cmake-build-debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_5c75c
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5c75c.dir/link.txt --verbose=1
/anaconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.14 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs CMakeFiles/cmTC_5c75c.dir/testCCompiler.c.o -o cmTC_5c75c
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_5c75c.dir/build.make:87: cmTC_5c75c] Error 1
make[1]: Leaving directory '/Users/hujinbo/CLionProjects/CppDemo/cmake-build-debug/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_5c75c/fast] Error 2以前的习惯是一有问题先百度谷歌,发现没有。自己仔细看了报错内容后,发现是 CMake 的 clang 包损坏了。重新升级安装了 anaconda,去 CMake 官网下载了app,添加系统路径后,搞定!
所以说,还是先要仔细看报错内容,有时候更节省时间。