[CMake] "Command line too long" under Windows

Brad King brad.king at kitware.com
Wed Oct 15 09:17:09 EDT 2008


Martin Apel wrote:
> I am currently in the process of trying to convert the build system of
> our software to CMake.
> Unfortunately there is one static library consisting of lots of objects
> (about 5700), which has lots of cyclic references, so I cannot easily
> split it up.
> I can generate this large library on Linux without problems. When trying
> to do the same under Windows, the build fails, because the link line is too
> long:
>   "CMakeFiles/spck.dir/objects.rsp : fatal error LNK1170: line in
> command file contains 131071 or more characters"

Have you ever built this library on Windows before?  You're hitting a
limitation of the native MSVC tools.

> An inspection of the file shows a single line with about 300.000
> characters. Is there any way to work around this problem besides
> splitting up
> the library? The CMake version I am using is 2.6.2 and I have tried with
> both the Visual Studio 8 generator (nmake) and the Unix makefile generator,
> but the problem shows up with both approaches.

CMake once just listed the object files on the command line in the
makefile, but users hit command line length limits with several hundred
object files.  We solved the problem by listing the objects in a
response file.  Now it looks like you've hit another limit of the MSVC
tools.  The fix to CMake will have to be to create *multiple* response
files each of which is under 131071 characters.  Please submit a request
here:

  http://www.cmake.org/Bug

Meanwhile, you can work around the problem just by splitting the library
into two pieces on Windows.  It should work easily because the MS linker
does not care about the order of static libraries.

-Brad


More information about the CMake mailing list