CLion cannot compile simple test program with Visual Studio

0
- 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

When attempting to use amd64, uwp, with bundled CMake.

I'm not sure what I can do to rectify this.

c++
cmake
visual-studio-2017
clion
asked on Stack Overflow Jan 27, 2020 by Daniel Paczuski Bak • edited Feb 8, 2020 by squareskittles

1 Answer

1

This issue appears to have one possible resolution on the CLion forums here. Essentially, you need to let CMake know that your platform is WindowsStore. You can update the CMake Options this via the CLion GUI (File > Settings > Build, Execution, Deployment > CMake), by adding the following flags:

-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10

Then, set your CLion platform to store, and try to rebuild.

answered on Stack Overflow Jan 27, 2020 by squareskittles • edited Jan 27, 2020 by squareskittles

User contributions licensed under CC BY-SA 3.0