CLion 无法使用 Visual Studio 编译简单的测试程序
Posted
技术标签:
【中文标题】CLion 无法使用 Visual Studio 编译简单的测试程序【英文标题】:CLion cannot compile simple test program with Visual Studio 【发布时间】:2020-01-27 19:52:06 【问题描述】:- The C compiler identification is MSVC 19.16.27035.0
-- The CXX compiler identification is MSVC 19.16.27035.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- broken
CMake Error at C:/Program Files/JetBrains/CLion 2019.1.3/bin/cmake/win/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/dbak/AppData/Local/Temp/cmake_check_environment/_build8400184188671408868/CMakeFiles/CMakeTmp
Run Build Command(s):nmake /nologo cmTC_a9318\fast
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_a9318.dir\build.make /nologo -L CMakeFiles\cmTC_a9318.dir\build
Building C object CMakeFiles/cmTC_a9318.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~1\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe @C:\Users\dbak\AppData\Local\Temp\nmD942.tmp
testCCompiler.c
Linking C executable cmTC_a9318.exe
"C:\Program Files\JetBrains\CLion 2019.1.3\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_a9318.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\10.0.17763.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\10.0.17763.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_a9318.dir\objects1.rsp @C:\Users\dbak\AppData\Local\Temp\nmDB46.tmp
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_a9318.dir\objects1.rsp /out:cmTC_a9318.exe /implib:cmTC_a9318.lib /pdb:C:\Users\dbak\AppData\Local\Temp\cmake_check_environment\_build8400184188671408868\CMakeFiles\CMakeTmp\cmTC_a9318.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_a9318.dir/intermediate.manifest CMakeFiles\cmTC_a9318.dir/manifest.res" failed (exit code 1120) with the following output:
MSVCRTD.lib(utility_app.obj) : error LNK2019: unresolved external symbol __imp_RoInitialize referenced in function __scrt_initialize_winrt
cmTC_a9318.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2019.1.3\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/dbak/AppData/Local/Temp/cmake_check_environment/_build8400184188671408868/CMakeFiles/CMakeOutput.log".
See also "C:/Users/dbak/AppData/Local/Temp/cmake_check_environment/_build8400184188671408868/CMakeFiles/CMakeError.log".
Error code: 1
当尝试将 amd64、uwp 与捆绑的 CMake 一起使用时。
我不确定我能做些什么来纠正这个问题。
【问题讨论】:
您是否在命令行上尝试过GCC 或Clang? 【参考方案1】:在 CLion 论坛here 上似乎有一种可能的解决方法。本质上,您需要让 CMake 知道您的平台是 WindowsStore
。您可以通过 CLion GUI(文件 > 设置 > 构建、执行、部署 > CMake)更新 CMake 选项,方法是添加以下标志:
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10
然后,将您的 CLion 平台设置为 store,然后尝试重建。
【讨论】:
以上是关于CLion 无法使用 Visual Studio 编译简单的测试程序的主要内容,如果未能解决你的问题,请参考以下文章
无法再使用 Visual Studio 2008 连接到 Visual Studio Team Services