You receive a “NMAKE : fatal error U1045: spawn failed : Invalid argument” error message when you compile a makefile by using the Microsoft Program Maintenance utility

When you compile a makefile by using the Microsoft Program Maintenance utility, Nmake.exe (NMAKE), you may receive the following error message:

NMAKE : fatal error U1045: spawn failed : Invalid argument

CAUSE

NMAKE uses the command interpreter to spawn the different tools that are needed to build the targets. The path to the command interpreter is found by querying for the value of the ComSpec environment variable. If the ComSpec environment variable is set incorrectly, you receive the error message shown in the “Symptoms” section.

RESOLUTION

To resolve this problem, ensure that the ComSpec environment variable is set correctly.

For Microsoft Windows NT and Microsoft Windows 2000, the command interpreter is Cmd.exe. The ComSpec environment variable should contain the following:

%SYSTEMROOT%\System32\Cmd.exe

To view and modify the ComSpec environment variable in Windows NT:

1. Open Control Panel.
2. Double-click the System icon, and then click the Environment tab.
3. Select the ComSpec variable, which is located in the System Variables box.
4. Modify the variable by using the Value edit box.

To view and modify the ComSpec environment variable in Microsoft Windows Server 2003, in Windows 2000, and in Windows XP, follow these steps:

1. Open Control Panel.
2. Double-click the System icon, click the Advanced tab, and then click Environment Variables.
3. Select the ComSpec variable, which is located in the System Variables box.
4. Click Edit to modify the variable.

For Microsoft Windows 95, Microsoft Windows 98, and Microsoft Windows Millennium (Me), the command interpreter is Command.com. The ComSpec environment variable should contain the following:

%WINDIR%\Command.com

To view the value of the ComSpec environment variable:

1. Start the command interpreter. Click Start, point to Programs, and then click MS-DOS Prompt.
2. At the command prompt, type set, and then press ENTER.

A list of all of the environment variables should be displayed in alphabetical order.

To correctly set the ComSpec environment variable:

1. Open the Autoexec.bat file and add the following line:

set ComSpec=%WINDIR%\Command.com

2. Save the Autoexec.bat file and restart the computer.

NOTE: On all these operating systems, ComSpec must not contain multiple paths. Only a single path is acceptable.

MORE INFORMATION

Steps to reproduce the behavior in Windows 2000

1. Start the command interpreter. Click Start, point to Programs, point to Accessories, and then click Command Prompt.
2. Type the following at the command prompt, and then press ENTER:

set ComSpec=%ComSpec%;%ComSpec%

3. Run NMAKE on your make file.

APPLIES TO
    Microsoft Visual C++ 5.0 Enterprise Edition
      Microsoft Visual C++ 6.0 Enterprise Edition
        Microsoft Visual C++ 5.0 Professional Edition
          Microsoft Visual C++ 6.0 Professional Edition
            Microsoft Visual C++, 32-bit Learning Edition 6.0
              Microsoft Visual C++ .NET 2002 Standard Edition
                Microsoft Visual C++ .NET 2003 Standard Edition
                  Microsoft Visual C++ 2005 Express Edition

                  You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

                  AddThis Social Bookmark Button

                  Leave a Reply

                  *
                  To prove that you're not a bot, enter this code
                  Anti-Spam Image