Hey, I’m having some trouble configuring cmake on my machine. I am attempting to build leptonica. I am on Windows 10, I have GCC 11.4.0 x86_64 and visual studio community 2022 release x86 as my compilers and I am using visual studio code as my text editor- I have visual studio installed because I was getting errors with GCC. I’m getting the error in the title, and the full output I get when I try to build in visual studio code is:
[main] Building folder: leptonica
[main] Configuring project: leptonica
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/Brian/Documents/GitHub/leptonica -Bc:/.../GitHub/leptonica/build -G "Visual Studio 17 2022" -T host=x86 -A win32
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is unknown
[cmake] CMake Error at CMakeLists.txt:42 (project):
[cmake] No CMAKE_C_COMPILER could be found.
[cmake]
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/.../GitHub/leptonica -Bc:/.../GitHub/leptonica/build -G "Visual Studio 17 2022" -T host=x86 -A win32 exited with code: 1
[visual-studio] Parse '\' failed
Any and all help is appreciated. I realize there is another topic with the same, well, topic, but the thread seems to have died a couple years ago and the original issue was never fully resolved, so here I am. Thank you in advance!
Hrm. It should be around after a compiler detection failure. Are there any other files around in CMakeFiles/ with hints? If even that fails, you might try --debug-trycompile and inspecting the trees CMake uses to do these things directly.
There is a CmakeConfigureLog.yaml file that I can’t upload in full that appeared in cmakefiles. The contents of the section marked “message” seem useful:
message: |
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
MSBuild version 17.7.2+d6990bcfa for .NET Framework
Build started 9/24/2023 6:22:30 PM.
Project "C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\\".
C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VC\\v170\\Microsoft.CppBuild.targets(513,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found. [C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj]
Creating directory "Debug\\CompilerIdC.tlog\\".
InitializeBuildStatus:
Creating "Debug\\CompilerIdC.tlog\\unsuccessfulbuild" because "AlwaysCreate" was specified.
Touching "Debug\\CompilerIdC.tlog\\unsuccessfulbuild".
VcpkgTripletSelection:
Using triplet "x86-windows" from "C:\\Users\\Brian\\Documents\\GitHub\\vcpkg\\installed\\x86-windows\\"
Using normalized configuration "Release"
ClCompile:
C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x86\\CL.exe /c /I"C:\\Users\\Brian\\Documents\\GitHub\\vcpkg\\installed\\x86-windows\\include" /nologo /W0 /WX- /diagnostics:column /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\\\" /Fd"Debug\\vc143.pdb" /external:W0 /Gd /TC /analyze- /FC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x86\\link.exe /ERRORREPORT:QUEUE /OUT:".\\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\\Users\\Brian\\Documents\\GitHub\\vcpkg\\installed\\x86-windows\\lib" /LIBPATH:"C:\\Users\\Brian\\Documents\\GitHub\\vcpkg\\installed\\x86-windows\\lib\\manual-link" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:\\Users\\Brian\\Documents\\GitHub\\vcpkg\\installed\\x86-windows\\lib\\*.lib" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\\CompilerIdC.lib" /MACHINE:X86 /SAFESEH Debug\\CMakeCCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'kernel32.lib' [C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj]
Done Building Project "C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj" (default target) (1) ->
(PrepareForBuild target) ->
C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VC\\v170\\Microsoft.CppBuild.targets(513,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found. [C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj]
"C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1181: cannot open input file 'kernel32.lib' [C:\\Users\\Brian\\Documents\\GitHub\\leptonica\\build\\CMakeFiles\\3.27.5\\CompilerIdC\\CompilerIdC.vcxproj]
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.55
When I trace this line C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VC\\v170\\Microsoft.CppBuild.targets(513,5)
to its respective file and line, the comments say it is to warn the user about missing environment variables. Could this be the case? I remember reading in the other post on this forum that the user was having some trouble with environment variables.
After reviewing the previous post again, I am modifying the installation of MSVC with windows 10 SDKs that come with VS community 2022. I will post if this works.