Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expanded command line too long

Tags:

c++

linker

nmake

I face with a problem in linking phase, while working with MSVC9 . It says:

NMAKE : fatal error U1095: expanded command line link.exe . . . too long

like image 752
Steve Frauhosen Avatar asked Feb 21 '23 10:02

Steve Frauhosen


2 Answers

You can get nmake to write the command line arguments to a file, then use the link option to read the arguments from the file.

Look for "inline files", eg http://msdn.microsoft.com/en-us/library/z440c98k(v=vs.80).aspx

It's a very long time since I did this, but as I recall the usage is something like:

foo.exe : foo1.obj foo2.obj foo3.obj
    link.exe @<<
foo1.obj
foo2.obj foo3.obj
... more arguments, macros etc on one or more lines
<<
    rem other commands go here if you want

Essentially you just have an ordinary nmake command line, but the pair of << markers tell nmake to write the options to a file (and they are replaced by the name of that file), and then @ tells link to read arguments from that file.

The KEEP option (possibly with a specified file name) can be useful for debugging - if link barfs, you can look in the file to see what you actually passed to it.

like image 150
Alan Stokes Avatar answered Mar 05 '23 19:03

Alan Stokes


There's not much you can do about fixed command line lengths in your tools. You might like to try and combine your object files into a couple of libraries, and then perform the final link and link the libraries together. This will introduce another step into your Makefile, but will get around the command line too long error.

like image 41
Tim Potter Avatar answered Mar 05 '23 19:03

Tim Potter