Erik Parker
Erik Parker

Reputation: 11

Windows RC.exe and long paths

I'm building an executable on windows using waf 2. The build includes multiple resource files. I'm using the latest windows sdk that I know of (version 10.0.19041.0). I'm encountering 2 separate but related issues. Both appear to be related to the windows resource compiler and long paths.

First, if one of the include paths includes spaces, then all of the include path arguments must either be on the command line or all of the include paths must be included in the INCLUDE environment variable. If I try to list the long paths in the INCLUDE environment variable and leave the rest of the include paths on the command line then I get the following error from rc.exe:

fatal error RC1107: invalid usage

If I either put all of the include paths in the INCLUDE environment variable or I list all of the include paths on the command line then this error does not occur.

If I let waf put all of the command line arguments in a response file rc.exe gives me the same error as above:

fatal error RC1107: invalid usage

In order to add all of the include paths to a response file I must use windows short path names.

So, if I have any include paths that are long paths, I must either force waf to not use response files or I need to put all of the include paths in the INCLUDE environment variable.

I'd really like to either put all of the command line arguments, including the long paths, in a response file, or I'd like to put the long paths into the INCLUDE environment variable and let waf handle the reset of the arguments automatically.

What, if anything, can I do to let rc.exe handle long paths in a response file? What, if anything, can I do to let rc.exe handle long paths in an environment variable and other paths on a response file?

Note that I have tried putting the long paths into quotes. I have also tried escaping the spaces in the long paths. Neither works.

Upvotes: 1

Views: 713

Answers (1)

desesc
desesc

Reputation: 11

I am having a similar issue when compiling resources with cmake. CMake does put all include into the VS project Resources->General->Additional Include Directories property.

I then see in the BuildLog.htm of the build the following:

Creating temporary file "RSP1.rsp" with contents
[
 /d "NDEBUG" /d "CMAKE_INTDIR=\"Release\"" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\cmake" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaaa" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaab" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaac" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaad" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaae" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaaf" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaag" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaah" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaai" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaaj" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaak" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaal" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaam" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaan" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaao" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\aaaaaaap" /fo "hello.dir\Release/description.res" "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\description.rc"
]
Creating command line "Rc @"D:\SharedwLnx\DebuggedCode\cmakeResources\hello\_build_vs19\hello.dir\Release\RSP1.rsp""

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.

fatal error RC1109: error creating "hello.dir\Release/description.res"

If I run Rc on the command line with the options above, it works just fine.

In case I reduce the number of includes, it is working fine as well. Though the relevant section in BuildLog.htm then is:

Compiling resources...
Rc /d "NDEBUG" /d "CMAKE_INTDIR=\"Release\"" /I "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\cmake" /fo "hello.dir\Release/description.res" "D:\SharedwLnx\DebuggedCode\cmakeResources\hello\description.rc"
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.

VS switched from running the Rc command directly, to generating RSP1.rsp and running Rc @"RSP1.rsp" when the command line would be long. And this breaks the resource compilation.

I did some experiments with a .rsp file I wrote myself. It looks like if it will contain apostrophes around .rc file name and include directories, the Rc @"RSP1.rsp" will fail, though I do not know the contents of the VS generated file.

Too me this looks like a bug in the Visual Studio component that is responsible for that .rsp file or a bug in Rc. I will thus change to custom generating the .res file and linking it to my executable.

Upvotes: 1

Related Questions