Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set cmake CXX variable on windows

Tags:

c++

windows

cmake

I am getting the following error

Working on: Microsoft Windows [Versión 6.1.7601]

ErrorS:

CMake Warning at CMakeLists.txt:4 (project):
  To use the NMake generator, cmake must be run from a shell that can use the
  compiler cl from the command line.  This environment does not contain
  INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
  work.


-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (project):
  The CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:4 (project):
  The CMAKE_CXX_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!

If somone can help...

like image 479
user3808307 Avatar asked Jul 25 '15 18:07

user3808307


People also ask

What does CXX mean in CMake?

This is a CMake Environment Variable. Its initial value is taken from the calling process environment. Preferred executable for compiling CXX language files. Will only be used by CMake on the first configuration to determine CXX compiler, after which the value for CXX is stored in the cache as CMAKE_CXX_COMPILER .

What is a CXX compiler?

CXX the C++ Compiler - the program understanding the C++ language, taking a .cc/.cpp source code file and generating a .o object file out of it. LD the linker - the program taking multiple .o files and libraries .so/.a (e.g. libboost) and generating an executable ELF file out of it - the final binary.

What is cmake_ CXX_ flags?

CMAKE_CXX_FLAGS is used to add flags for all C++ targets. That's handy to pass general arguments like warning levels or to selected required C++ standards. It has no effect on C or Fortran targets and the user might pass additional flags.


2 Answers

You need to run the batch script provided by Visual Studio to set up your environment before running cmake. It's under X:\Visual\Studio\Dir\VC\vcvarsall.bat. There should also be a shortcut in the start menu for "Visual Studio Command Prompt" that will open a prompt and automatically run vcvarsall.bat.

like image 163
Miles Budnek Avatar answered Sep 23 '22 15:09

Miles Budnek


Please note that I resolved the problem by adding this to my PATH environment variable where I have Visual Studio 2019 installed:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.20.27508\bin\Hostx64\x64
like image 44
user8128167 Avatar answered Sep 24 '22 15:09

user8128167