'The command line is too long' when linking .obj files in Windows command prompt

1.5k Views Asked by At

As a last step to my maven build on Windows, it tries to create a dll file by linking around 1500 object files. Looks something like this:

cl.exe foo.dll (around 1500 .obj files) (couple of other statically linked libraries)

The build fails with just one statement: The command line is too long.

Have tried to search the solution here, here and here but the solutions are more context specific rather than something more generic. Could any one suggest what I can do?

1

There are 1 best solutions below

1
On BEST ANSWER

I think I got the answer to my question. I can bundle the arguments of the command in an .rsp file and fire it up on my command prompt with the executable after prepending its path by '@'. So, for this command:

cl.exe foo.dll (around 1500 .obj files) (couple of other statically linked libraries)

I put this

foo.dll (around 1500 .obj files) (couple of other statically linked libraries)

inside a file say makeDLL.txt. Change it to a .rsp file by changing its extension (makeDLL.rsp) and fire up this command:

cl.exe @<full-path of makeDLL.rsp>

This worked for me.