我正在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