CLion EWDK MSVC Toolchain doesn't find kernel32.Lib
Morning,
I am currently moving my whole dev environment from VS2019 to CLion and can't get the Enterprise Windows Driver Kit (WDK) build environment working. After setting up the toolchain I get the following error message:
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: E:/Program Files/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: E:/Program Files/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/JetBrains/CLion 2021.3.2/bin/cmake/win/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"E:/Program Files/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: A:/Git/School/Driver/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/JetBrains/CLion 2021.3.2/bin/ninja/win/ninja.exe cmTC_02d23 && [1/2] Building C object CMakeFiles\cmTC_02d23.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_02d23.exe
FAILED: cmTC_02d23.exe
cmd.exe /C "cd . && "C:\Program Files\JetBrains\CLion 2021.3.2\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_02d23.dir --rc="E:\PROG#OLC\WIND#B-J\10\bin\1002#1AM.0\x86\rc.exe" --mt="E:\PROG#OLC\WIND#B-J\10\bin\1002#1AM.0\x86\mt.exe" --manifests -- "E:\PROG#OLC\MICR#M1~\2019\BUIL#ZPH\VC\Tools\MSVC\1428#Y8D.299\bin\Hostx64\x64\link.exe" /nologo CMakeFiles\cmTC_02d23.dir\testCCompiler.c.obj /out:cmTC_02d23.exe /implib:cmTC_02d23.lib /pdb:cmTC_02d23.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 && cmd.exe /C "cd /D A:\Git\School\Driver\cmake-build-debug\CMakeFiles\CMakeTmp && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file A:/Git/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary A:/Git/School/Driver/cmake-build-debug/CMakeFiles/CMakeTmp/cmTC_02d23.exe -installedDir A:/Git/vcpkg/installed/x64-windows-static/debug/bin -OutVariable out""
LINK Pass 1: command "E:\PROG#OLC\MICR#M1~\2019\BUIL#ZPH\VC\Tools\MSVC\1428#Y8D.299\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_02d23.dir\testCCompiler.c.obj /out:cmTC_02d23.exe /implib:cmTC_02d23.lib /pdb:cmTC_02d23.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_02d23.dir/intermediate.manifest CMakeFiles\cmTC_02d23.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)
So my guess would be that CLion isn't able to find the correct Windows Kit that includes the missing static linked libs.
When working with VS2019 this issues is not existing as `LaunchBuildEnv.cmd` will take care of setting all paths.
Basically you just start `LaunchBuildEnv.cmd` then type `SetupVSEnv` and start VS2019 from the cmd and all paths etc. are fixed automatically.
Unfortunately this doesn't work for CLion. When pointing CLion to the `Build Tools` folder it is able to detect everything correctly but seems to no be able to get the Windows Kits from `E:\Program Files\Windows Kits\10`.
I already tried to supply CLion with `SetupBuildEnv.cmd` as the Environment File without any success.
So I wanted to ask if somebody know how I need to supply this path to CLion so it is correctly forwarded to cl.exe.
Regards Artur
Please sign in to leave a comment.
Hello!
Please go to File | Settings | Build, Execution, Deployment | CMake and paste the following options into the CMake options field:
Does it help?
Anna Falevskaya
Thanks for the response but the flags didn't helped.
Is there any information that I could provide to you?
Please provide a screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).
I really appreciate your help.
Here is the requested screenshot:
As far as I can tell the issue is caused by the generator I guess because then I switch to VS2019 as the generator everything works fine. Although I the compiler checks are then just skipped.
And when using ninja I get this:
>As far as I can tell the issue is caused by the generator I guess because then I switch to VS2019 as the generator everything works fine.
Is it ok for you to use this generator?
For sure, just wanted to let you know this if some other person has the same error.
Thanks for your time.
Have a nice weekend.
Thanks for sharing the solution! Hope you have a nice weekend too!