I would like to compile an application with using Clang 4.0, CMake 3.8.1, MinGW x86_64 6.3.0. I've tried:
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=clang.exe -DCMAKE_CXX_COMPILER=clang++ ..\code
but a compilation of a test program failed because of passing Visual Studio's compiler arguments. I'd like to not use Visual Studio at all. Output:
-- The C compiler identification is Clang 4.0.0
-- The CXX compiler identification is Clang 4.0.0
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files/LLVM/bin/clang.exe" is not able to compile a simple test program.
clang.exe: error: no such file or directory: '/nologo'
clang.exe: error: no such file or directory: '/DWIN32'
clang.exe: error: no such file or directory: '/D_WINDOWS'
I also tried:
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/msbuild-bin/cl.exe" -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/msbuild-bin/cl.exe" -DCMAKE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe" ..\code
and it also failed while compilation a test program:
C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo
@CMakeFiles\cmTC_afe59.dir\objects1.rsp /out:cmTC_afe59.exe
/implib:cmTC_afe59.lib
/pdb:C:\...........\_build\CMakeFiles\CMakeTmp\cmTC_afe59.pdb
/version:0.0 /machine:x64 /debug /pdbtype:sept /INCREMENTAL:YES
/subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib
error: could not open /pdbtype:sept: no such file or directory
Is it possible to force Clang with MinGw on Windows 10?
Those are MSVC parameters. I have come across several libraries that assume these work when checking for IF(WIN32)
in CMakeLists.txt
, while it should be IF(MSVC)
.
There is a MinGW-w64 available with both GCC and LLVM/CLang at http://winlibs.com/ but as it's not MSVC those parameters still need to be avoided, so I recommend you fix CMakeLists.txt
and run cmake again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.