Error configuring UWP toolchain in CLion


I'd like to use CLion to develop a Windows UWP application but have not been able to get the MSVC UWP toolchain working in CLion.

When I try to configure a UWP toolchain, I get "Test CMake run finished with errors" with error:

error LNK2019: unresolved external symbol __imp_RoInitialize referenced in function __scrt_initialize_winrt

I'm using CLion version: 2019.2.4

CLion successfully detects version 16 of the Visual Studio tools (at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community) and I'm able to build non-UWP programs successfully (leaving the Architecture, Platform, and Version selections empty).

I've tried different combinations of Architecture, Platform, and Version. For example:

Architecture: amd64

Platform: uwp

Version: 10.0.18362.0

I'm using the Bundled CMake (I also tried the version from Visual Studio, but get the same results)

Any help would be awesome. Thanks!



-- The C compiler identification is MSVC 19.23.28106.4
-- The CXX compiler identification is MSVC 19.23.28106.4
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- broken
CMake Error at C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/simon/AppData/Local/Temp/cmake_check_environment/_build4546935093374661642/CMakeFiles/CMakeTmp

Run Build Command(s):nmake /nologo cmTC_26741\fast && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_26741.dir\build.make /nologo -L CMakeFiles\cmTC_26741.dir\build
Building C object CMakeFiles/cmTC_26741.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx64\x64\cl.exe @C:\Users\simon\AppData\Local\Temp\nm8627.tmp
Linking C executable cmTC_26741.exe
"C:\Program Files\JetBrains\CLion 2019.2.3\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_26741.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_26741.dir\objects1.rsp @C:\Users\simon\AppData\Local\Temp\nm8696.tmp
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_26741.dir\objects1.rsp /out:cmTC_26741.exe /implib:cmTC_26741.lib /pdb:C:\Users\simon\AppData\Local\Temp\cmake_check_environment\_build4546935093374661642\CMakeFiles\CMakeTmp\cmTC_26741.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_26741.dir/intermediate.manifest CMakeFiles\cmTC_26741.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_26741.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2019.2.3\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX64\x64\nmake.exe"' : return code '0x2'

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/simon/AppData/Local/Temp/cmake_check_environment/_build4546935093374661642/CMakeFiles/CMakeOutput.log".
See also "C:/Users/simon/AppData/Local/Temp/cmake_check_environment/_build4546935093374661642/CMakeFiles/CMakeError.log".

Error code: 1


Comment actions Permalink


Please try the following: set the platform option to store, go to File | Settings | Build, Execution, Deployment | CMake and paste the following options into the CMake options field:


Does it help?

Comment actions Permalink

Thank you for your help.

With the changes that you suggest above, I'm able to build a sample program.

I think I understand what is happening now: the options that I set in the Visual Studio Toolchain window (Architecture, Platform, and Version) are provided to vcvarsall.bat to configure the tool environment. But I then need to separately instruct CMake to build a Windows Store application. Is that correct?

Comment actions Permalink

Simon, I'm glad it helped! Yes, it seems you’re right.

Comment actions Permalink

Thanks again for your help.


Please sign in to leave a comment.