Skip to content

Add support for compiling .rc files into Windows .res files #3702

@leximayfield

Description

@leximayfield

I tried to compile an old Win32 C program with a build.zig and didn't see an obvious happy path to compile an .rc file into a .res file and add it to the build. These seem to be somewhat common in Win32 projects, so I think that if the intention is to support gradually converting Win32 C programs to Zig, being able to easily compile resource files and add them to the target should be part of that.

LLVM comes with llvm-rc, and it worked for me, but unlike windres and whatever the MSVC resource compiler is, llvm-rc doesn't run the preprocessor against the source file, so a preprocessing step with clang -E is also necessary. However, once you get a .res file out of it, it can be added to the build with addObjectFile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.enhancementSolving this issue will likely involve adding new logic or components to the codebase.os-windowsMicrosoft WindowsproposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions