[CMake] Error running link command: Argument list too long

Brad King brad.king at kitware.com
Fri Aug 1 09:13:07 EDT 2008


Andrew Sayman wrote:
> On Thu, Jul 31, 2008 at 10:30 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
>> Try 2.6.1 RC 16 and see if it is fixed.
>>
>> What OS/Generator/Compiler are you using?
> 
> It didn't help. I'm using RHEL5.1 / Unix Makefiles / gcc-4.1.2
> 
> I may have actually stated the problem incorrectly. I'm building a
> static library with a lot of object files in it. When it's done it
> just makes one long `ar cr <OBJECTS>` list and the list is too long.

All the fixes you've seen are for Windows with its 32k command line 
length limit.  This is the first time I've seen someone with so many 
object files that it gives Linux a problem.  What is the error message 
that you get?

Try adding the lines below to your project (just to see if it helps, not 
as a permanent solution).  They're from Windows-gcc.cmake and are used 
for long link lines on Windows.  They tell CMake how to split up the 
static archive creation into multiple invocations of the archiver.  If 
this helps we can probably just use the same thing for all platforms.

-Brad


SET(CMAKE_C_ARCHIVE_CREATE
     "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_APPEND
     "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
SET(CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
SET(CMAKE_CXX_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
SET(CMAKE_CXX_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})


More information about the CMake mailing list