Similar to CMake: Visual Studio 15 2017 could not find any instance of Visual Studio but in my case I've got my main installations version of MSVC generator working. It's the 2017 generator that doesn't seem to be working for me. Here is my installation setup:
My understanding is that this should work, I should have the appropriate tools.
When I run cmake -G "Visual Studio 16 2019" ../
I get
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.28.29337.0
-- The CXX compiler identification is MSVC 19.28.29337.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/.../build
Looks good so far. But when I run cmake -G "Visual Studio 15 2017" ../
I get
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/.../build/CMakeFiles/CMakeOutput.log".
I'm currently use this version of cmake:
cmake -version
cmake version 3.20.0-rc2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
so I should have all the latest methods of using cmake.
I know I could manually configure the generators, but that sticks with the cmake cache and gets deleted constantly, and I was under the impression CMake could handle multiple visual studio instances with out such manual tuning, and that I should be able to use environment variables to point to each one at the very least, though that also doesn't appear to be working.
If you want to generate targeting the Visual Studio 2017 platform toolset (v141), but using Visual Studio 2019 as the generator, you'd use the following CMake generate command
cmake -G "Visual Studio 16 2019" -T v141 ..
I think this is a case of unfortunate naming. Installing the "VS 2017 C++ x64/x86 build tools" only installs the compiler, linker and standard libraries and not actually the entire "Visual Studio Build Tools 2017" which include MSBuild. But you need the latter to use the "Visual Studio 15 2017" generator. You can find the installer for the 2017 build tools at https://aka.ms/vs/15/release/vs_buildtools.exe
I want to build Tensorflow C++ on Windows 10 using CMake. However I cannot pass the COMPILER_OPT_ARCH_NATIVE_SUPPORTED test, which resulting in failed building attempts. Here is my open issue on tf github repo: https://github.com/tensorflow/tensorflow/issues/24076, which has received no response thus why I am asking on stackoverflow and hopefully someone here can enlighten me. I am running out of ideas now. I have tried Python 3.5 and 3.6, visual studio 2017 and 2015. All with no success.
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
TensorFlow installed from (source or binary): source
TensorFlow version: the latest version
Python version: 3.6
Bazel version (if compiling from source): I am using CMake
GCC/Compiler version (if compiling from source): gcc 6.30
CUDA/cuDNN version: Installing only the CPU version
I am also using Microsoft Visual Studio Community 2017 Version 15.9.3, btw
Describe the problem
I am following the "Step by step Windows Build" from https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake. However, at step 3, I can't seem to pass Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED, which resulting failed building process.
Provide the exact sequence of commands / steps that you executed before running into the problem
PS C:\Users\bw\tensorflow\tensorflow\contrib\cmake\build> cmake .. -A x64 -Thost=x64 -DCMAKE_BUILD_TYPE=Release `
>> -DSWIG_EXECUTABLE='C:\Program Files\swigwin-3.0.12\swig.exe' `
>> -DPYTHON_EXECUTABLE='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe' `
>> -DPYTHON_LIBRARIES='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\libs\python36.lib'
-- Building for: Visual Studio 15 2017
CMake Warning at CMakeLists.txt:9 (message):
Your current cmake generator is set to use 32 bit toolset architecture.
This may cause "compiler out of heap space" errors when building. Consider
using the flag -Thost=x64 when running cmake.
-- The C compiler identification is MSVC 19.16.27024.1
-- The CXX compiler identification is MSVC 19.16.27024.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed
-- Performing Test MSVC_OPENMP_SUPPORT
-- Performing Test MSVC_OPENMP_SUPPORT - Success
-- Found PythonInterp: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version "3.6.7")
-- Found PythonLibs: optimized;C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36.lib;debug;C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36_d.lib (found version "3.6.7")
-- Found SWIG: C:/Program Files/swigwin-3.0.12/swig.exe (found version "3.0.12")
CMake Error at tf_python.cmake:811 (string):
string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
CMakeLists.txt:583 (include)
CMake Error at tf_python.cmake:812 (string):
string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
CMakeLists.txt:583 (include)
CMake Error at tf_python.cmake:813 (string):
string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
CMakeLists.txt:583 (include)
-- Configuring incomplete, errors occurred!
See also "C:/Users/bw/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/bw/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeError.log".
Any other info / logs
CMakeOutput.log: https://www.dropbox.com/s/7fweyunxdbmxa1k/CMakeOutput.log?dl=0
CMakeError.log: https://www.dropbox.com/s/tucx0tl6346kdpd/CMakeError.log?dl=0
The first line of the guide states:
CMAKE build is deprecated for TensorFlow. Please use bazel to build TF for all platforms. For details, see the TensorFlow install guide.
Apparently you need to use a release version that is known to build correctly via CMAKE on Windows. Probably should switch to the recommended build system if you want to build the latest code.
Looking at the CMakeLists.txt file for this project shows that Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed is the step where it checks if the compiler accepts the -march=native flag. It doesn't, see this fix https://github.com/tensorflow/tensorflow/issues/8724#issuecomment-289326917.
The actual errors are due to a scripting issue in tf_python.cmake that cannot properly parse one of the source files. It seems to me that the issues are unrelated.
Like many others i have problems using boost libraries with windows. On Ubuntu 16.04 it works all very well with libboost-all-dev but on windows i have many problems.
I try to build a cryptonote application which i can compile completely without any errors under linux. But i need also windows binaries so i did the steps to install the following tools:
Visual Studio 2013 (vc120)
CMake 3.10.1
Python 3.6.4
Boost 1.58
For boost i did the following steps:
Installing boost from binary
Run bootstrap.bat
Run b2 install
Run bjam install "--with-some-libs"
Nothing works. The cryptonote throws me an error that some but not all libraries could not be found.
I tried to set the BOOST_ROOT, BOOST_LIBRARY_DIRS, BOOST_INCLUDE_DIRS -> Nothing.
What i did wrong? The error i get from cmake is this:
-- Building for: Visual Studio 12 2013
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1928 (message):
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: C:/local/boost_1_58_0
Could not find the following static Boost libraries:
boost_system
boost_filesystem
boost_thread
boost_date_time
boost_chrono
boost_regex
boost_serialization
boost_program_options
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:113 (find_package)
-- WARNING: Git was not found!
-- Found PythonInterp: C:/Users/chris/AppData/Local/Programs/Python/Python36-32/python.exe (found version "3.6.4")
CMake Warning in CMakeLists.txt:
CMAKE_SKIP_INSTALL_RULES was enabled even though installation rules have
been specified
-- Configuring incomplete, errors occurred!
See also "C:/Users/chris/Documents/GitHub/cryptonote/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/chris/Documents/GitHub/cryptonote/build/CMakeFiles/CMakeError.log".
Maybe someone can help to fix this issue ?
Greetings
Ok finally i've found a solution after reading many, many and many more pages on the internet.
The solution is really simple. After downloading the boost package and installing it (or building from source) you just need the following two parts:
Open your CMD (cmd.exe)
switch to your installation directory of boost (example C:\local\boost_1_58_0)
Just run the following commands:
bootstrap.bat
b2 link=static runtime-link=static release stage
This will create all librarys static and makes it useable for cmake.
This solution works for me and made me able to build the needed package.
Thanks for all helpers
Or you could just tell boost which compiler to use by adding
toolset=msvc-12.0
(for MS 2013 v12, etc.)
to the b2 command line :-)
I have VS2017 installed, with both VS2017 (v141) and VS2015.3 (v140) toolset installed. I need to generate a solution with CMake and I want CMake to be "fooled" as if VS2015 is installed, so I can build the project with v140 toolset.
I know this question is possibly a duplicate of:
How cmake specify "Platform Toolset" for a Visual Studio 2015 project?
But the solution it provides doesn't help me.
The error messages are:
Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.15063.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:18 (project):
No CMAKE_C_COMPILER could be found.
I tried installing both VS2017 and VS2015.3 (IDE), but VS2015.3 refused to create even a simple console program.
Is there another way to generate a solution with v140 toolset?
(P.S. Don't tell me that I should generate with v141 toolset first and modify the toolset option in Visual Studio. That makes a big difference. )
I've just ran a test and it works for me with the following settings in CMake's GUI (Version 3.10.0 RC4):
Then I get the following output:
The CXX compiler identification is MSVC 19.0.24215.1
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
Generating done
And if I open the resulting solution it will - as expected - ask me:
Platform Toolset Mapping
From Marco Foco: Microsoft Visual C++ version Map:
If that don't work ...
First please check the CMakeError.log in your binary output directory. The error should give you a lead on what's wrong.
If that's not helping, you can try several things (besides re-installing VS, which I think won't solve the problem):
One of the Windows SDKs is not fully/correclty installed; Reinstall from Microsoft's web site
Try to give the cmake-gui administrative rights
Check if there is a GNU toolchain with GCC compiler in your PATH environment.
References
VS 2010 and CMake: 'rc' is not recognized as an internal or external command
MSBuild.exe has stopped cmake error
Environment variable used by CMake to detect Visual C++ compiler tools for Ninja
We are having trouble compiling a project using CMake (v2.8.12) under Windows 7 64Bit using Visual Studio 2012. CMake gives us the following errors. We already tried starting Cmake from the Visual Studio Command Line using admin rights. There seems to have been a similar bug in CMake 2.8.11: http://www.cmake.org/Bug/view.php?id=14440
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The C compiler identification is unknown
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:127 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The CXX compiler identification is unknown
Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
CMake Warning at src/CMakeLists.txt:44 (message):
SWIG was not found. You will not be able to compile for C#.
Configuring incomplete, errors occurred!
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeOutput.log".
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeError.log".
I had the same issue and fixed it running cmake as Admin
Those error messages
The C compiler identification is unknown
The CXX compiler identification is unknown
means CMake did find or assume a compiler but it wasn't able to compile a simple test program.
Take a look at CMakeFiles\CMakeError.log and check the error message there to see:
which compiler path/command line CMake did use
what the error message calling the compiler was
e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
If you add --debug-trycompile to the cmake call CMake will even keep the files it has tried to test compile (so you can copy/paste/re-run the command line from the error log in your cmd shell).
The last time I had this problem ...
The last time I had this problem was when my Visual Studio 2012 Professional standard installation did not install any Windows SDK (the error log was showing an missing SDK header).
To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe
Since I was missing this - or more accurate any SDK - I installed Windows 8.1 SDK (since Visual Studio 2012 does target Windows 8.x) and voila my CMake was able again to compile the (test) programs.
Reference
Does Visual Studio 2012 include the full Windows SDK
CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I was getting the terminal output:
The C compiler identification is unknown
The CXX compiler identification is unknown
I checked the CMakeError.log output:
\build\CMakeFiles\CMakeError.log
It showed the error:
warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.
Going back to visual Studio I needed to install the Windows 10 SDK:
After installing the SDK and running cmake it showed:
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.28.29334.0
The CXX compiler identification is MSVC 19.28.29334.0
And built successfully!
I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514 is missing.
After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.
http://www.microsoft.com/en-us/download/details.aspx?id=36020
I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:
Open command prompt for developers from Visual Studio tools.
Goto the directory where cmake.exe is present.
Run it.
Lets hope it works for you as well.
For some reason, deleting the build folder in my machine, solved the issue.
cmake:
The cmake assume that you set g++ compiler path accurately.In case due any reason if it did't find compiler path{/usr/bin/g++} then it throw an error like:
**The CXX compiler identification is unknown**
So given step will short out this error:
Locate your compiler CXX path{for g++ path under Linux is :/usr/bin/g++}
Set the Compiler Path and export it configuration: PATH=/usr/bin:$PATH;export PATH
Export compiler like : export CXX=/usr/bin/g++-7
Here we assume that g++,cmake,build-essential install in your Linux system...!!
Same problem here with cmake 2.8.12 and visual studio 10. Cmake may not be able to find the compiler. I solved the problem by uninstalling latest version and installed cmake 2.8.10.
I just encounter with this issue, after I uninstalled some MS software.
I fixed it by repair visual studio 2012.
First go to [Control panel], then select visual studio and repair it,things will go right now.
Make sure you select the proper version of visual Studio.
For example, Visual Studio 2012 is version 11.
I had the same problem and I had to use the "File -> Delete Cache", since I accidentally configured CMake to use wrong visual studio version.
If you use CMake 3.4.0, try upgrading to a newer version. A bug concerning this was fixed relatively recently (see the bug report).
Make sure that you have installed Clang tools
open tools -> Get tools and features, select individual components, search cmake, then uninstall cmake and then re-install cmake, when complete, restart your computer.
I was seeing this on ubuntu - issue was cmake was assuming clang++ as c compiler.
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/clang++-9"
To fix it, export C, C++ compiler paths:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++