2017-06-29 370 views
1

我试图在运行Windows 10的计算机上安装一组可执行文件,并且在下载源代码之后,我需要使用cmake编译它们。我下载了最新版本的CMake的,和(设置适当的工作目录后)一直在努力,以安装可执行文件运行在Windows命令提示符下输入以下命令:为什么cmake没有找到编译器cl

mkdir build 
cd build 
cmake ../ 
make 

然而,cmake的一贯命令产生以下错误,并不能产生任何形式的make文件中的make命令可以使用:

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

    cl 

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

    To use the NMake generator with Visual C++, cmake must be run from a shell 
    that can use the compiler cl from the command line. This environment is 
    unable to invoke the cl compiler. To fix this problem, run cmake from the 
    Visual Studio Command Prompt (vcvarsall.bat). 

    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:2 (project): 
    The CMAKE_CXX_COMPILER: 

    cl 

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

    To use the NMake generator with Visual C++, cmake must be run from a shell 
    that can use the compiler cl from the command line. This environment is 
    unable to invoke the cl compiler. To fix this problem, run cmake from the 
    Visual Studio Command Prompt (vcvarsall.bat). 

    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! 
See also "C:/Users/Hannah/Documents/nupack3.2.0/build/CMakeFiles/CMakeOutput.log". 
See also "C:/Users/Hannah/Documents/nupack3.2.0/build/CMakeFiles/CMakeError.log". 

我已经尝试了许多解决方案,为cmake的工作,和他们都没有工作。我试图将我的cmake文件夹的bin添加到我的PATH环境变量中,我试图重新安装我的cmake副本,并尝试使用CMake GUI来生成make文件(Running CMake on Windows),甚至下载Visual Studio (How to set cmake CXX variable on windows),但因为我没有足够的经验来使用CMake GUI或Visual Studio,或者因为还有其他问题,所以似乎没有任何工作,cmake ../产生完全相同的错误。

任何人都可以为我提供一些备用解决方案,以便如何使此命令有效吗?

+0

***在Windows命令提示符下***我将使用您正在使用的Visual Studio版本的Visual Studio命令提示符。或者至少在命令提示符下执行vcvarsall.bat。这就是说你不要在Visual Studio中使用'make'。 – drescherjm

+0

你在CMake中使用了什么发电机?你使用什么编译器? – drescherjm

+0

***我试图将我的cmake文件夹的bin添加到我的PATH环境变量中***我的窗口中有我的路径中的CMake bin。我每天在一台半打电脑上用Visual Studio进行CMake。 – drescherjm

回答

1

已经下载了他们的二进制文件后,我需要使用cmake

这是没有意义的编译它们。您可以下载来源并需要编译它们,或者您下载了二进制文件,并且不需要编译任何其他文件。

如果事实证明你需要编译,你将不得不安装一个编译器(比如Visual Studio)。一旦安装VS,CMake应该没有问题找到它(当使用VS发电机时)。

然而,您的错误消息似乎表明使用NMake生成器,它需要从正确配置用于构建的命令提示符运行。在安装Visual Studio时,应该在开始菜单中提供开发命令提示符的快捷方式。为您的平台启动正确的并从那里运行CMake。

+0

对于术语混淆的问题,我对这些流程很陌生。我的意思是说我已经下载了源代码并需要编译它们。我现在将更正我的文本 –

+0

另外,我已经在命令提示符下多次运行NMake生成器,但它仍然不起作用。我也尝试过使用其他生成器(https://stackoverflow.com/questions/4101456/running-cmake-on-windows),但它没有区别 –