tags:

views:

689

answers:

2

Does anyone knows 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!

A: 

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'.

Jonathan Leffler
How do I do it manually?
the_drow
+4  A: 

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).

Mike Weller
It works, thanks :)
the_drow
Why Visual Studio wasn't configured this way in the first place? Any clue?
the_drow
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.
Mike Weller