Strange error occurred while using cmake

10,453

Solution 1

I googled for the cmd.exe error and came up with this page. Looks like Visual studio needs to be configured with a few paths so it knows how to find cmd.exe. Here are the steps from that thread:

What you must do is change MSVS options (Tools menu > Options > Project and Solutions > VC++ Directories) to ensure that

$(SystemRoot)

$(SystemRoot)\System32

$(SystemRoot)\System32\wbem

are specified BEFORE $(PATH).

Solution 2

Check if any other tool that you have installed overwrote the PATH variable. In my case this happened and the symptom (link error) was the exact same.

Solution 3

The key line is probably:

1>Project : error PRJ0003 : Error spawning 'cmd.exe'.

For some reason or another, the MSVC is not able to execute 'cmd.exe', and therefore the compilation fails.

I would guess that the problem might be related to the setting of %PATH%; there might be some other reason for the trouble.

Try doing what CMake did manually - see whether you get the same error. This will help you diagnose whether the problem is in CMake (if it does work for you from the command line) or in your general environment (if it does not work for you either).


Learn how to read error messages!

Change Dir: I:/SophisPal/build/CMakeFiles/CMakeTmp

Run Build Command:C:\PROGRA~1\MICROS~1.0\Common7\IDE\VCExpress.exe CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec

These are two of the early lines in the output. The first indicates that CMake changed directory to one of its creating. The second indicates the command it ran there. You would also need to find out what files it created in the directory before running the command.

With that information at hand, you'll have to go through the same steps - 'cd' followed by 'vcexpress'.

Solution 4

I came across the same problem on VS 7 .NET 2003.

Fixed by adding

<MSVS .NET 2003 Home>\Vc7\bin
<MSVS .NET 2003 Home>\Common7\IDE

paths to VC++ Directories (Tools menu > Options > Projects > VC++ Directories)

Real cause of the problem is that:

  1. cl.exe is not found in system or MSVS path;
  2. cl.exe requires mspdb71.dll.
Share:
10,453
the_drow
Author by

the_drow

My name is Omer Katz and I am a very passionate software developer who specializes in ALM &amp; SCM practices. I'm also an Agile &amp; Lean enthusiast and practitioner. I am only 23, therefor I have only started working in the industry in 2010 but I have been programming since I was 11 and I have never stopped being passionate about it. I have a vast knowledge when it comes to planning, designing, developing &amp; delivering software. My greatest passion is finding new ways to make the developers' lives easier and let them focus on what they know to do best, software development.

Updated on June 13, 2022

Comments

  • the_drow
    the_drow almost 2 years

    Does anyone know what "The C compiler "cl" is not able to compile a simple test program." means?
    I am trying to compile Wt using CMake on MSVC 9.
    The OS is Windows XP.
    Here is the full log:

    Check for working C compiler: cl Check for working C compiler: cl -- broken CMake Error at I:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:50 (MESSAGE): The C compiler "cl" is not able to compile a simple test program.

    It fails with the following output:

    Change Dir: I:/SophisPal/build/CMakeFiles/CMakeTmp

    Run Build Command:C:\PROGRA~1\MICROS~1.0\Common7\IDE\VCExpress.exe CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec

    Microsoft (R) Visual C++ Express Edition Version 9.0.30729.1.

    Copyright (C) Microsoft Corp 2007. All rights reserved.

    1>------ Build started: Project: cmTryCompileExec, Configuration: Debug Win32 ------

    1>Compiling...

    1>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86

    1>Copyright (C) Microsoft Corporation. All rights reserved.

    1>cl /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "CMAKE_INTDIR=\"Debug\""
    /D "_MBCS" /FD /RTCs /MDd /Fo"cmTryCompileExec.dir\Debug\"
    /Fd"I:/SophisPal/build/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec.pdb" /W3 /c /Zi /TC /Zm1000

    1> .\testCCompiler.c

    1>testCCompiler.c

    1>Compiling manifest to resources...

    1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1

    1>Copyright (C) Microsoft Corporation. All rights reserved.

    1>Linking...

    1>Embedding manifest...

    1>Project : error PRJ0003 : Error spawning 'cmd.exe'.

    1>Build log was saved at
    "file://i:\SophisPal\build\CMakeFiles\CMakeTmp\cmTryCompileExec.dir\Debug\BuildLog.htm"

    1>cmTryCompileExec - 1 error(s), 0 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    CMake will not be able to correctly generate this project. Call Stack (most recent call first):
    CMakeLists.txt:7 (PROJECT)

    Configuring incomplete, errors occurred!

  • the_drow
    the_drow over 14 years
    How do I do it manually?
  • the_drow
    the_drow over 14 years
    Why Visual Studio wasn't configured this way in the first place? Any clue?
  • Mike Weller
    Mike Weller over 14 years
    Maybe for security reasons it doesn't include these paths in the build system. I can imagine somebody downloading a malicious project that calls "cmd /k del /s /f /q c:*.*" as part of the build.
  • pdinklag
    pdinklag about 13 years
    This solution worked greatly for me with VS2008, but VS2010 has made the "VC++ Directories" a project-based setting. Now, I don't have any project, cmake is to generate them after all. How could I solve this for VS2010?
  • Dennis Mathews
    Dennis Mathews over 11 years