UnrealBuildTool should use a command file for CL.exe

I just download the source for 4.7 and everything’s working, except I can’t package my game.

UBT crashes with a Win32Exception saying the command line is too long. It passes 33 thousand characters on the command line to CL.exe.

I had to do some quick hacky changes to UBT to use a command file instead to allow my game to package.

Read more about CL command files here CL Command Files | Microsoft Docs

Hi ,

Were you trying to package using the Promoted branch or the Master branch on GitHub? Neither one of those branches are truly considered stable, though Promoted is the more stable of the two since it has gone through some minimal testing.

This was on the promoted branch, yes.

Sorry for the delayed response. I have reached out to one of our developers for some additional information regarding this issue, but I don’t expect a response until after the holiday.

Thanks for reporting this. Sorry that you’re unable to package, but I’m glad you were able to create a simple workaround. We’re going to look into using Response Files as you suggested, or greatly shortening the number of parameters required to pass to CL.exe if we can. Sorry about that!

I just wanted to provide a quick update. We have created a ticket to track this issue (UE-7102).

Hi,

Did you happen to see which file UBT was failing at? There have been some recent fixes related to command line length when building UELinkerFixups, and I’m wondering if this would have addressed your problem.

Steve

bump
has this matter been resolved?? im having this issue as well

Hi ,

Sorry to hear that you are running into this issue. The original ticket was marked as resolved for version 4.7. Due to the age of this post, could you please create a new post in the Bug Reports section with some additional information about what steps you take to get to this issue, and the results that you observe when it occurs?

For future answer seekers getting this error, you can fix it by adding bLegacyPublicIncludePaths = false; to your [ProjectName].Build.cs file (or whichever module is failing).

This requires you to fix all your header includes though, but that’s just healthy for your project.
The reason your build is failing is because legacy behavior is to append all public include paths to the build tool’s command line. This doesn’t scale and fails eventually as a project grows for tools with smaller commandline buffer. Turning off legacy include paths stops appending them to the command line at the cost of you having to put in the actual correct path for each header. But you’d want to have correct include paths anyways, right? :slight_smile:

UE4 has a commandlet to help with fixing your include paths:
RunUAT.bat RebasePublicIncludePaths -Project="path/to/project.uproject" -UpdateDir="path/to/code" -Write

If you have many modules you might want to turn it on for all of them, but you can also put that same boolean into your *.Target.cs files to force it for all modules in your targets.