我正在Windows上使用Clang 3.8和CMake 3.7构建一个C++项目,但Clang在配置发出错误,如下所示。Windows上的Clang和CMake
Determining if the CXX compiler works failed with the following output: Change Dir: C:/tools/k.build/CMakeFiles/CMakeTmp Run Build Command:"C:/tools/ninja.exe" "cmTC_c0004" [1/2] Building CXX object CMakeFiles/cmTC_c0004.dir/testCXXCompiler.cxx.obj [2/2] Linking CXX executable cmTC_c0004.exe FAILED: cmTC_c0004.exe cmd.exe /C "cd . && C:\tools\llvm-3.8.1.build\Release\bin\clang++.exe CMakeFiles/cmTC_c0004.dir/testCXXCompiler.cxx.obj -o cmTC_c0004.exe -Wl,--out-implib,libcmTC_c0004.dll.a -Wl,--major-image-version,0,--minor-image-version,0 && cd ." LINK : warning LNK4044: unrecognized option '/-out-implib'; ignored LINK : warning LNK4044: unrecognized option '/-major-image-version'; ignored LINK : warning LNK4044: unrecognized option '/-minor-image-version'; ignored LINK : fatal error LNK1181: cannot open input file 'libcmTC_c0004.dll.a' clang++.exe: error: linker command failed with exit code 1181 (use -v to see invocation) ninja: build stopped: subcommand failed.
奇怪的是CMakeFiles/CMakeTmp /中没有文件存在。我怎样才能使它工作?
您是否尝试删除二进制输出'k.build'并再次尝试从头开始?看起来像你切换编译器,例如从'gcc'到'clang'放在同一个输出目录中。你也可以尝试一个最小的例子,像[这里](http://stackoverflow.com/questions/38171878/how-do-i-tell-cmake-to-use-clang-on-windows)。 – Florian
不知何故,您的配置已损坏。以'/ -'开始的选项显然是错误的,'.dll.a'也看起来很奇怪。你如何引用CMake?它检测到什么编译器? – usr1234567
@Florian是的,我删除了k.build中的输出,并尝试了一次又一次的其他设置。这些项目是为Linux开发的,我将它移植到Windows上。 – HenryK