Problems generating a solution for VS 2017 with CMake

So, I installed Visual Studio 2017 yesterday. I also installed CMake 3.7.2, which supports VS 2017.

My VS installation with the Game development with C++ + workflow Game development with C++ several other components:

individual_components

I also added CMake stuff (but I don’t think I even needed it), since I use CMake as a standalone tool for creating VS-solutions) and MSBuild (I had msbuild.exe before adding this component - so I'm not sure what exactly does this additional component do).

With VS 2015, I was able to just run cmake . from the normal command line to solve.

With VS 2017, the workflow is changing - I read this post from Microsoft .

So, I tried the following:

  • I opened Developer Command Prompt for VS 2017 , and from it I launched cmake . -G "NMake Makefiles" cmake . -G "NMake Makefiles" . Then do cmake --build . correctly compiled everything.
  • When I tried the following at the prompt: cmake . -G "Visual Studio 15 2017 Win64" cmake . -G "Visual Studio 15 2017 Win64" to get the solution to be created, I got the following errors:

     -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:3 (project): No CMAKE_C_COMPILER could be found. CMake Error at CMakeLists.txt:3 (project): No CMAKE_CXX_COMPILER could be found. -- Configuring incomplete, errors occurred! 

I also tried to configure the environment using vswhere.exe and run vcvarsall.bat as follows:

"C: \ Program Files (x86) \ Microsoft Visual Studio \ 2017 \ Community \ VC \ Auxiliary \ Build \ vcvarsall.bat" amd64

and again, I could only generate NMake files, not a solution.

So how can I get a solution?

And why does cl.exe tell Version 19.10.25017 when it is in VC\Tools\MSVC\14.10.25017\bin ?

+18
c ++ visual-c ++ visual-studio cmake visual-studio-2017
Mar 09 '17 at 16:51
source share
3 answers

Turning my comments back

Error -- The CXX compiler identification is unknown - No CMAKE_CXX_COMPILER could be found. basically means that CMake was unable to compile a simple test program (which it always runs as part of the compiler identification / verification).

You can look at CMakeFiles\CMakeError.log (relative to your binary output directory), the cause of the error should be there.

Two possible reasons why I have reached so far:

  • Missing administrator rights. You can try to run this again from the shell with administrator privileges for cross-checking if your Visual Studio has been configured with administrator privileges.

  • Missing Windows SDK. Check the SDK installation, for example. make sure you have some kind of resource compiler. It should be on a path like:

     C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe 

Install Visual Studio 2017

Note that Visual Studio cannot install all the necessary C ++ packages, even if you select one of the predefined C ++ packages (for example, I used Desktop development with C++ , and then added additional packages under the Individual Components tab).

Here is the choice that worked for me (VS2017 Community Edition, Windows 10):

enter image description here

If you have projects using the MFC / ATL libraries, you need to add them under the SDKs, libraries, and frameworks subcategory:

enter image description here

References

  • CMake error in CMakeLists.txt: 30 (project): No CMAKE_C_COMPILER can be found
  • CXX compiler id unknown
  • VS 2010 and CMake: 'rc' is not recognized as an internal or external command
+16
Mar 11 '17 at 18:22
source share

I am using Windows 7 .... And after @Florian told me in the comments to look in CMakeFiles/CMakeError.log , I managed to fix this problem!

Here is the first magazine:

 Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: Build flags: Id flags: The output was: 1 Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C) Microsoft Corporation. All rights reserved. Build started 3/10/2017 11:05:24 AM. Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets). C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\v141\Toolset.targets(36,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj] Done Building Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED. Build FAILED. "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) -> (Desktop_PlatformPrepareForBuild target) -> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\v141\Toolset.targets(36,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.28 Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: Build flags: Id flags: The output was: 1 Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C) Microsoft Corporation. All rights reserved. Build started 3/10/2017 11:05:24 AM. Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets). C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\v141\Toolset.targets(36,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj] Done Building Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED. Build FAILED. "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) -> (Desktop_PlatformPrepareForBuild target) -> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\v141\Toolset.targets(36,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.13 

I seemed to need the Windows SDK version 8.1 , so I installed it as a component (only for version 10). But then another error appeared:

 Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: Build flags: Id flags: The output was: 1 Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C) Microsoft Corporation. All rights reserved. Build started 3/10/2017 11:17:21 AM. Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "Debug\". Creating directory "Debug\CompilerIdC.tlog\". InitializeBuildStatus: Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. ClCompile: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TC /errorReport:queue CMakeCCompilerId.c CMakeCCompilerId.c Link: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj] Done Building Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED. Build FAILED. "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) -> (Link target) -> LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdC\CompilerIdC.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:01.04 Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: Build flags: Id flags: The output was: 1 Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C) Microsoft Corporation. All rights reserved. Build started 3/10/2017 11:17:22 AM. Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "Debug\". Creating directory "Debug\CompilerIdCXX.tlog\". InitializeBuildStatus: Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. ClCompile: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TP /errorReport:queue CMakeCXXCompilerId.cpp CMakeCXXCompilerId.cpp Link: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj] Done Building Project "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED. Build FAILED. "D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) -> (Link target) -> LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [D:\doctest\build\CMakeFiles\3.8.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.60 

So LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' sounds the same as I needed to install more components - and so I did:

  • Visual C++ runtime for UWP
  • Windows Universal CRT SDK

And after that the problem disappeared!

+4
Mar 10 '17 at 11:33
source share

If you have the SDK for Windows 10 Creator Update installed, it does not install executable files for desktop computers by default to preserve the installation size. CMake will always try to use the latest SDK when compiling, which will fail because it will not have binaries like "gdi32.lib" (the first error that occurs to me).

Microsoft lists this as a "Known Release", see Known Visual C ++ Desktop Issues .

The updated Windows 10 Developer SDK has been reorganized to reduce the default installation. When you install this SDK through UWP, it will not install the headers / libraries required for Win32 C ++ Desktop Projects.

To fix this problem, you need to change the installation of Visual Studio to enable the Windows 10 SDK (10.0.15063.0) for the desktop.

Install Creator Desktop SDK

+2
Jul 25 '17 at 10:12
source share



All Articles