Fatal NMAKE Error U1045 May Be Caused By a Long Command Line

ID Number: Q72729

1.00 1.01 1.10 1.11 1.12 1.13 | 1.01 1.10 1.11 1.12 1.13

MS-DOS | OS/2

Summary:

If the length of a command line in a makefile exceeds the operating

system limit, NMAKE may produce the following error:

NMAKE: fatal error U1045: spawn failed: Arg list too long

In DOS, the maximum command line length is 128 characters. Under OS/2,

the limit is 255 characters.

More Information:

The NMAKE error documentation gives only the following explanation for

the U1045 error:

Fatal NMAKE error U1045

'internal error message'

Note the circumstances of the error and notify Microsoft Corp.

by following the instructions in the Microsoft Product Assistance

Request form at the back of one of your manuals.

In the case that the 'internal error message' is "spawn failed: Arg

list too long," the workaround is to shorten the command line that is

too long. If the command line is a LINK or a LIB command line, a

response file can be used to overcome the limit. If the command line

is a compiler command line, it might be possible to eliminate a few

unnecessary options or use the CL environment variable.

In the following sample make file, the link command line exceeds 128

characters, which results in a U1045 error under DOS. The workaround

in this case is to create a linker response file as shown below.

Sample NMAKE Makefile

---------------------

ALL: test.exe

.c.obj:

cl /c /AL $*.c

test.exe: module1.obj \

module2.obj \

module3.obj \

module4.obj \

module5.obj \

module6.obj \

module7.obj \

module8.obj

link /CO /E /F /INF /M /PACKC /PACKD /ST:4096 module1.obj \

module2.obj module3.obj module4.obj module5.obj module6.obj \

module7.obj module8.obj

Workaround

----------

To work around this problem, a linker response file can be created.

For this example, the response file might contain the following:

/CO /E /F /INF /M /PACKC /PACKD /ST:4096 module1.obj+

module2.obj+

module3.obj+

module4.obj+

module5.obj+

module6.obj+

module7.obj+

module8.obj

test.exe

test.map

;

To utilize this file, the LINK line in the sample makefile above

should be changed to the following:

link @test.lrf

For information on automatically generating the response file through

the NMAKE inline file capability, see your printed NMAKE documentation

or select the link to "Inline Files" from the NMAKE contents screen in

the online help.