So I installed Visual Studio 2017 yesterday. I also installed CMake 3.7.2 which supports VS 2017.
My VS installation is with the Game development with C++
workflow + a few other components:
I've also added the CMake stuff (but I don't think I even needed it - since I'm using CMake as a standalone tool to just generate the VS solutions) and MSBuild (I had msbuild.exe
even before adding that component - so not sure what exactly does that additional component do).
With VS 2015 I was able to just run cmake .
from a normal command prompt for a solution.
With VS 2017 the workflow changes - I've read this post from Microsoft.
So I tried the following:
- I opened the
Developer Command Prompt for VS 2017
and from it I rancmake . -G "NMake Makefiles"
. Then runningcmake --build .
compiled everything properly. When I tried the following in the prompt:
cmake . -G "Visual Studio 15 2017 Win64"
to force the creation of a solution 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 setting up the environment using vswhere.exe and running vcvarsall.bat
like this:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
and again I could only generate NMake files and not a solution.
So how can I get a solution?
And why does cl.exe
report Version 19.10.25017
when it's in VC\Tools\MSVC\14.10.25017\bin
?
I'm using Windows 7.... And after @Florian told me in the comments to look into
CMakeFiles/CMakeError.log
I managed to fix the problem!Here is the first log:
It seemed I needed
Windows SDK version 8.1
so I installed it as a component (had only version 10 installed). But then there was another error:So
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib'
sounds a lot like I needed to install more components - and so I did:Visual C++ runtime for UWP
Windows Universal CRT SDK
And after that the problem is gone!
If you have the Windows 10 Creator's Update SDK installed, it doesn't install the desktop binaries by default, in order to keep the installation size down. CMake will always try to use the latest SDK when it compiles, which will fail as it will be missing binaries such as "gdi32.lib" (that's the first error that occurs for me).
Microsoft list this as a "Known Issue", see Visual C++ Desktop Known Issues.
In order to fix the problem, you need to modify the Visual Studio installation to include the
Windows 10 SDK (10.0.15063.0)
for Desktop component.For me ,I installed vs2015 before,and the c compiler 2015 work before,when i install vs2017, get the same error
can't find compiler
. And when i runcmake ..
in the vs2017 developer command,it works. And i can specify generetor to vs2015 or vs2017,it all works.Turning my comments into an answer
The error
-- The CXX compiler identification is unknown - No CMAKE_CXX_COMPILER could be found.
basically means that CMake wasn't able to compile a simple test program (which it always does as part of identifying/validating the compiler).You can take a look into
CMakeFiles\CMakeError.log
(relative to your binary output directory), the error reason should be in there.Two possible reasons I came across so far:
Missing administrator rights. You can try running this again from a shell that has administrative rights to crosscheck if your Visual Studio was setup with the need for administrator rights.
Missing Windows SDK. Verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
Visual Studio 2017 Installation
Please note the Visual Studio may not install all necessary C++ packages even when you select one of the C++ pre-defined packages (as I have e.g. used
Desktop development with C++
and then added more packages under theIndividual Components
tab).Here is which selection worked for me (VS2017 Community Edition, Windows 10):
If you have projects using MFC/ATL libraries you need to add it under
SDKs, libraries, and frameworks
subcategory:References