View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005719CMakeCMakepublic2007-09-16 11:252008-10-01 13:40
ReporterAndrew Molloy 
Assigned ToBill Hoffman 
PrioritynormalSeveritytextReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0005719: NMake Makefiles generator doesn't work "out of the box" with Visual Studio C++ 2005 Express Edition
DescriptionThe NMake Makefiles generator doesn't work "out of the box" with Visual Studio C++ 2005 Express Edition. CMake will issue errors regarding its inability to find RC.exe and CL.exe. This situation can be resolved with relative ease, but as far as I could tell, it is not documented anywhere. Below you will find steps to reproduce this issue, as well as steps the user can take to correct it, and a proposed solution.

Steps to Reproduce:
1. Start with a completely fresh install of Wndows XP or Windows 2000 (I've tried this with both. I haven't tried Vista).
2. Make sure the Windows installation is completely up to date, with all service packs and Windows Updates.
3. Download and install Visual C++ 2005 Express Edition from http://msdn2.microsoft.com/en-us/express/aa975050.aspx. [^] Accept all of the default options.
4. Complete the registration as requested by Microsoft.
5. Install the Visual Studio 2005 Express Editions SP1, which you can download from http://www.microsoft.com/downloads/details.aspx?familyid=7b0b0339-613a-46e6-ab4d-080d4d4a8c4e&displaylang=en. [^] The file you want is VS80sp1-KB926748-X86-INTL.exe.
6. Download and install the Microsoft Platform SDK (These steps were reproduced on an x86 machine, so the version of the SDK I tried with is PSDK-x86.exe), as described here: http://msdn2.microsoft.com/en-us/express/aa700755.aspx. [^]
7. In the SDK installer, accept all of the defaults.
8. As described in "Step 3" on http://msdn2.microsoft.com/en-us/express/aa700755.aspx, [^] modify the Visual C++ directories by adding the following paths to each subsection in the Projects and Solutions section in the Options dialog box:
* Executable files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
* Include files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include
* Library files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib
9. As described in "Step 4" on http://msdn2.microsoft.com/en-us/express/aa700755.aspx, [^] update the file corewin_express.vsprops, which should be located in C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults. Change the string that reads
AdditionalDependencies="kernel32.lib"
to
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"
10. As described in "Step 5" on http://msdn2.microsoft.com/en-us/express/aa700755.aspx, [^] update the file AppSettings.htm, which should be found on C:\Program Files\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\1033\. Comment out lines 441 - 444 by putting a // in front of them, as shown:
// WIN_APP.disabled = true;
// WIN_APP_LABEL.disabled = true;
// DLL_APP.disabled = true;
// DLL_APP_LABEL.disabled = true;
11. Download and install CMake 2.4.7 from http://cmake.org/HTML/Download.html. [^] I used cmake-2.4.7-win32-x86.exe. I selected "Add CMake to the system PATH for all users". Otherwise, I used all of the default settings.
12. Open up a command prompt: Click Start->Run, in the new dialog box, type "cmd" (without the quotes) and press Enter.
13. Type the following at the command prompt:
mkdir test
cd test
mkdir src
mkdir build
cd src
copy con CMakeLists.txt
PROJECT(test)
^Z
exit

The "^Z" is Control-Z.

14.Click Start->Programs->Cmake 2.4->CMake
15.For "Where is the source code:", type "C:\Documents and Settings\USERNAME\test\src" where USERNAME is your windows user name.
16. For "Where to build the binaries:", type "C:\Documents and Settings\USERNAME\test\build" where USERNAME is your windows user name.
17. Click "Configure"
18. Select "NMake Makefiles" then click "OK".
19. A dialog box will appear:
"CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found. Please set CMAKE_RC_COMPILER to a valid compiler path or name."
20. You will, of course, not be able to build the project from this point.

Proposed Solution
This is mostly a documentation issue, since it can be resolved by following some simple steps. I've described the steps below. I believe they should be added to the documentation (though perhaps in better words than I could manage). It would also be nice if the various CMake scripts the NMake Makefiles generator relies on, such as CMakeDetermineRCCompiler.cmake, referred the user to this documentation when they fail.

When installing the Platform SDK, select "Custom" for the installation type. Accept the default setting for "Installation Location". On the "Custom Installation" screen, change "Register Environmental Variables" from "Will not be available" to "Will be installed on local hard drive." You can also run the installer again if the PSDK is already installed. If you do this, select to "Add/Remove" then continue from "On the 'Custom installation' screen..." above.

This eliminates the missing rc.exe message, but now you'll get this error:

"CMake Error: your C compiler: "cl" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name."

If you run CMakeSetup.exe from the Visual Studio 2005 Command Prompt, this error is eliminated.

You can also fix this error, without having to use the Visual Studio 2005 Command Prompt, by adding the appropriate variables to your system environment. You need the PATH, INCLUDE, LIB, and LIBPATH variables from whichever script vcvarsall.bat executes on your setup. In nearly all cases, this is vcvars32.bat, which can be found in c:\Program Files\Microsoft Visual Studio 8\Common7\Tools. From this file:

1. Do Start->Settings->Control Panel->System. Click the Advanced tab, then the "Environmental Variables" button.
2. From vcvars32.bat, copy the PATH variable, except for the trailing ";%PATH%". Back in the Environmental Variables window, double click the already existing PATH variable in either the User variables, add a ; to the end of what's already there, then paste and click OK.
3. From vcvars32.bat, copy the INCLUDE variable, except for the trailing ";%INCLUDE%". Back in the Environmental Variables window, double click the already existing INCLUDE variable in either the User variables , add a ; to the end of what's already there, then paste and click OK.
4. From vcvars32.bat, copy the LIB variable, except for the trailing ";%LIB%". Back in the Environmental Variables window, double click the already existing LIB variable in either the User variables, add a ; to the end of what's already there, then paste and click OK.
5. From vcvars32.bat, copy the LIBPATH variable. Back in the Environmental variables window, click New for either User variables. Name the new variable LIBPATH, and paste in the value. Click OK.
6. Click OK in the Environment Variables window, then again for System Properties.

After following these steps, the NMake Makefiles generator will work without any issues.
TagsNo tags attached.
Attached Files

 Relationships
has duplicate 0004248closedBill Hoffman when user32.lib missing, suggest user install Platform SDK 

  Notes
(0009000)
Bill Hoffman (manager)
2007-09-16 11:38

How about this:

1. Install your compiler, and make sure it can compile helloworld.cxx from the command line.

cl helloworld.cxx

When this works, cmake will work from the same command line.

helloworld.cxx:
#include <iostream>
int main(int , char** ) { std::cout << "hello world\n"; return 0; }
(0009006)
Bill Hoffman (manager)
2007-09-16 13:19

I think this not really a bug report. Perhaps you should make a FAQ entry on the wiki instead...
(0009009)
Brandon Van Every (reporter)
2007-09-16 20:07

I don't think the nmake stuff is FAQ material. It does need to go on the http://www.cmake.org/Wiki/CMake_Generator_Specific_Information [^] page though.

We probably need a better FAQ entry for VC++ 2005 Express issues in general, with pointers to more specific info. These really do come up all the time.

Diagnosing VC++ 2005 Express setup issues is an ongoing problem. It comes in different guises. I think it would help CMake's adoption if it were more proactive about diagnosing these issues and giving better error messages about them. But that's a feature request, not a bug per se.

I wonder if VC++ 2008 Express will have similar issues? Seems likely, given Microsoft is in charge. They'll probably always dumb down the free stuff and not fix minor problems, so that you have an incentive to buy the full priced Visual Studio rather than cobble together a free development environment.
(0009011)
Andrew Molloy (reporter)
2007-09-17 08:07

Unfortunately, the first suggestion (get the environment to a point where you can build a simple hello world program) isn't adequate to solve the problem. You can build that program just after having installed Visual Studio C++ 2005 Express without installing the Platform SDK, or performing any of the other steps necessary to get CMake to work (I tried as a sanity check, just to be sure).

Re: Visual C++ 2008 Express, I've installed the Beta version of it and can confirm that, at least at this point, it has the same issues.

Re: http://www.cmake.org/Wiki/CMake_Generator_Specific_Information, [^] there are some instructions listed there that technically work, but require the user to launch CMakeSetup.exe from a command line. While being able to launch it from the command line is well and good (and, in fact, how I launch it in most cases), I would imagine there are plenty of users who would try launching it from the icon the installer places on the desktop, find it doesn't work, and give up.

I submitted this mostly as a documentation request. Adding better error messages would be, to me, just a nice bonus.
(0009021)
Brandon Van Every (reporter)
2007-09-17 11:36

You're welcome to put more correct information on the appropriate wiki page. I don't presume that the nmake directions on that wiki page are correct or complete.
(0012454)
David Abrahams (reporter)
2008-06-22 22:23

Personally I think this is way more than a documentation issue. CMake is supposed to "just work" and VS 2008 is arguably the most popular C++ development environment anywhere. I don't see why the tool shouldn't handle this case more gracefully. It should allow users to install the tools in whatever way they feel is appropriate (in particular, it shouldn't require them to pollute their default environment with SDK-specific variables) and it should respond appropriately.
(0012457)
Bill Hoffman (manager)
2008-06-23 09:16

OK, this is a technical issue. There is no easy way for CMake to do this. CMake can not set the environment, because it is no longer running when nmake takes over and does the build. It is not CMake's fault that the MS compiler wants you to pollute your environment. CMake makes the valid assumption, that the compiler is in good working order before CMake is run.
(0012468)
David Abrahams (reporter)
2008-06-23 13:14

"It is not CMake's fault that the MS compiler wants you to pollute your environment. CMake makes the valid assumption, that the compiler is in good working order before CMake is run."

I disagree completely. First of all, it has been pointed out in this ticket several times that the compiler *is* in good working order before CMake is run; CMake is simply choking on the lack of an available .RC (resource file) compiler, which would only be needed in a tiny minority of all cross-platform projects and is *not* part of the C/C++/linking toolchain per se.

Secondly, it's easy to handle these cases correctly. Boost.Build does it by invoking any Microsoft-supplied .bat scripts that are needed to set up the environment as part of each compilation/linking command. Depending on how CMake invokes build commands, you could also handle this stuff by invoking the .bat scripts during configure to see what they do to the environment, and simply re-create the environment variable settings in the nmake file.

I really want to switch over to CMake, and convince others to do the same, but the case will be really hard to make if it doesn't handle these issues well.
(0012469)
Bill Hoffman (manager)
2008-06-23 13:27

CMake would have to run the .bat script for every invocation of the compiler. You have to remember that cmake is no longer running at the time nmake is running. nmake is the process running and not CMake. CMake generates the build files and then it is done. It can not affect the build time environment. Instead of calling the compiler directly from nmake, I suppose you could call some .bat file. We could make CMake more forgiving of a missing RC compiler I suppose.
(0012470)
David Abrahams (reporter)
2008-06-23 13:29

"CMake would have to run the .bat script for every invocation of the compiler."

Exactly. That's what Boost.Build does (when necessary). So what's the problem?

"We could make CMake more forgiving of a missing RC compiler I suppose."

That too!
(0012471)
Bill Hoffman (manager)
2008-06-23 13:30

One more thing, there is no reason to pollute the environment. I run cmake from the cygwin command line all the time. I just source a vsSetup.bash file that sets all the paths before I do. Or, I run the cmd shells that come with visual studio that setup the environment. If you want to use the IDE and not the command line, then you should not need to do anything but pick a different generator. If you like the command line, you should be able to set a few environment variables before using the compiler.
(0012472)
David Abrahams (reporter)
2008-06-23 13:32

"If you like the command line, you should be able to set a few environment variables before using the compiler."

In general, sure... but not if that means figuring out how to satisfy some obscure CMake requirement (e.g., RC compiler in the path) that has nothing to do with the real needs of my project.
(0012473)
Bill Hoffman (manager)
2008-06-23 13:35

Seems like running the .bat each time would be slow. I think boost build since it is a process that is running at build time, can run the .bat file once, then invoke the compiler lots of times. We would have to run the .bat every time the compiler is run, which I am guessing would add a huge overhead.
(0012474)
Bill Hoffman (manager)
2008-06-23 13:38

Due to a recent change in cmake, making rc optional is very easy, and I have made a commit:

$ cvs commit -m "ENH: make rc optional" Windows-cl.cmake
Committer: Bill Hoffman <bill.hoffman@kitware.com>
/cvsroot/CMake/CMake/Modules/Platform/Windows-cl.cmake,v <-- Windows-cl.cmake
new revision: 1.86; previous revision: 1.85
(0012475)
Bill Hoffman (manager)
2008-06-23 13:40

Running the .bat files each time will not be easy at all. I use gmake on windows with MSVC, and it would not even be able to run a .bat file. nmake might be able to, but not gmake. Again, I think it would be very slow.
(0012476)
David Abrahams (reporter)
2008-06-23 14:03

"I think boost build since it is a process that is running at build time, can run the .bat file once, then invoke the compiler lots of times."

Bill, it seems like you're not listening to me. I already told you twice that Boost.Build does *not* do that, "Boost.Build does it by invoking any Microsoft-supplied .bat scripts that are needed to set up the environment as part of each compilation/linking command..." and "``"CMake would have to run the .bat script for every invocation of the compiler.'' Exactly. That's what Boost.Build does (when necessary)"

you can always invoke cmd from gmake if you need to. This stuff doesn't slow Boost.Build down appreciably (and yes, it builds with VC++ with cygwin make, or used to). If you're really, really worried about speed you can always compile your own front-end tool that sets up the environment and then invokes cl, or heck, just generate an additional layer of nmake file that sets up the environment.

Anyway, taking care of the RC compiler issue is a big step in the right direction, and I'm not going to insist that you take care of all possible cases. Still, I feel somewhat obliged to stick up for the point of view that it is basically possible to make the tool work with a straight-up installation of the toolchain and no fiddling from the user.
(0012477)
Bill Hoffman (manager)
2008-06-23 14:15

Running cmd will have other issues. Running our own front end will still have to setup the env for every invocation. I am concerned about speed, and the use of cmd from gmake. At some point we plan to create a tool called cbuild that will be a replacement for gmake/nmake. At that point it might make sense to suck in the env for visual studio, as you could do it once per build. I still don't think it is too much to ask that the tool chain is installed and working as the manufacturer of the toolchain expects. If you want to use nmake/cl together, you have to setup the environment that is what vsvars.bat and the cmd shells on the start menu are for.
(0012506)
Bill Hoffman (manager)
2008-06-24 15:58

Sorry, I had to undo the optional rc stuff. It did not work... Also, as it turns out with vs 2005 and newer, we use the rc tool to embed manifests into executables and dll's. So, we really do need it for things to work correctly. It is not just for applications that compile windows resources anymore.
(0012510)
David Abrahams (reporter)
2008-06-24 20:00

Are you saying that it is necessary to use the RC tool that comes with a separate SDK in order to build .EXEs or .DLLs with Visual C++ 9.0 Express Edition? That would mean that VS Express basically can't be used out of the box, which I find really hard to believe.

I just looked at the Boost.Build MSVC toolset and it uses the manifest tool, "mt," to do that job. I'd be willing to bet that is part of VC 2008 Express, but if it isn't, there simply *has* to be another way to do this.
(0012511)
Bill Hoffman (manager)
2008-06-24 21:19

Yup, you can use mt directly, except that you can not get incremental linking to work correctly without a trick that you do with rc and the manifest stuff.
(0012512)
David Abrahams (reporter)
2008-06-24 21:28
edited on: 2008-06-24 21:29

So CMake requires that I install the platform SDK and go through a 6-step setup process whether or not I want incremental linking. I don't think it's a very good design choice for usability, especially not for the "build-to-install" crowd. Incremental linking is a development-time optimization, not something that's needed in order to work correctly, and if I haven't installed the parts needed to support the incremental linking feature I don't think CMake should penalize me.


 Issue History
Date Modified Username Field Change
2007-09-16 11:25 Andrew Molloy New Issue
2007-09-16 11:38 Bill Hoffman Note Added: 0009000
2007-09-16 13:19 Bill Hoffman Note Added: 0009006
2007-09-16 20:07 Brandon Van Every Note Added: 0009009
2007-09-17 08:07 Andrew Molloy Note Added: 0009011
2007-09-17 11:36 Brandon Van Every Note Added: 0009021
2007-11-19 10:07 Alex Neundorf Category CCMake => CMake
2007-12-17 21:40 Bill Hoffman Status new => assigned
2007-12-17 21:40 Bill Hoffman Assigned To => Bill Hoffman
2008-06-22 22:23 David Abrahams Note Added: 0012454
2008-06-23 09:16 Bill Hoffman Note Added: 0012457
2008-06-23 13:14 David Abrahams Note Added: 0012468
2008-06-23 13:27 Bill Hoffman Note Added: 0012469
2008-06-23 13:29 David Abrahams Note Added: 0012470
2008-06-23 13:30 Bill Hoffman Note Added: 0012471
2008-06-23 13:32 David Abrahams Note Added: 0012472
2008-06-23 13:35 Bill Hoffman Note Added: 0012473
2008-06-23 13:38 Bill Hoffman Note Added: 0012474
2008-06-23 13:40 Bill Hoffman Note Added: 0012475
2008-06-23 14:03 David Abrahams Note Added: 0012476
2008-06-23 14:15 Bill Hoffman Note Added: 0012477
2008-06-24 15:58 Bill Hoffman Note Added: 0012506
2008-06-24 20:00 David Abrahams Note Added: 0012510
2008-06-24 21:19 Bill Hoffman Note Added: 0012511
2008-06-24 21:28 David Abrahams Note Added: 0012512
2008-06-24 21:29 David Abrahams Note Edited: 0012512
2008-10-01 13:40 Bill Hoffman Status assigned => closed
2008-10-01 13:40 Bill Hoffman Resolution open => won't fix
2008-10-09 13:26 Bill Hoffman Relationship added has duplicate 0004248


Copyright © 2000 - 2018 MantisBT Team