12.5.1 Command line too long (Windows® OS)

When a project’s makefile is run, each command that is executed is passed to the local native shell. For Windows operating systems, there is a limit of 8191 characters. Therefore, for a project with hundreds of C files that link, the limit could be surpassed and this error will be displayed.

Linux OS and macOS can usually take very long command lines. If you want to find out the length limit for your system, you can type on the command line getconf ARG_MAX.

Response File Workaround

If you are using the MPLAB XC8 or MPLAB XC32 C compiler v1.01 and above, or MPLAB XC16 C compiler v1.22 and above or MPLAB XC-DSC C compiler v3.00 and above, you may be able to use a response file when calling the linker to work around this issue.

Table 12-1. Project Properties* Response File Selection
Compiler Categories Option categories
MPLAB XC8 XC8 linker Additional Options > Use response file to link
MPLAB XC16 xc16-ld General > Use response file to link
MPLAB XC-DSC xc-dsc-ld General > Use response file to link
MPLAB XC32 xc32-ld General > Use response file to link

* To open the Project Properties window, see 5.3 Open Project Properties.

Library Workaround

For all other compilers, you can create an MPLAB X IDE library project and move some source files from your main project to the library project. Then add the library project to your main project.

To create a library project select File > New Project

, click the Microchip Embedded category, and then select Library Project as the project.

To add the library to your main project, open the Project Properties window i.e., File > Project Properties), click in Categories under Libraries, and then click the Add Library Project button.

Archive Checkbox Workaround

For MPLAB XC16, MPLAB XC-DSC and MPLAB XC32, there is now a check box you can use when archiving long sets of files into libraries that might push the link line over the character limit. The Break into multiple lines option can be used to tell the compiler to break up the archive line into smaller lines to avoid this limitation.

Find this option in:

Project Properties window, xc16-ar, xc-dsc-ar or xc32-ar category, General option category, Break into multiple lines check box.