LinuxCommandLibrary

windres

GNU Windows resource compiler

TLDR

Compile resource script to COFF object file

$ windres [input.rc] -o [output.o]
copy
Compile to binary resource format
$ windres -O res [input.rc] -o [output.res]
copy
Convert res file to COFF object
$ windres -i [input.res] -o [output.o]
copy
Specify input format explicitly
$ windres -I rc -i [input.rc] -O coff -o [output.o]
copy
Include directory for headers
$ windres --include-dir=[path/to/includes] [input.rc] -o [output.o]
copy
Define preprocessor symbol
$ windres -D [SYMBOL=value] [input.rc] -o [output.o]
copy
Cross-compile for 64-bit Windows
$ x86_64-w64-mingw32-windres [input.rc] -o [output.o]
copy

SYNOPSIS

windres [-i infile] [-o outfile] [-I format] [-O format] [-F target] [--include-dir dir] [-D sym] [options]

DESCRIPTION

windres is the GNU resource compiler for Windows applications, part of GNU Binutils. It compiles resource script (.rc) files containing UI elements like icons, cursors, menus, dialogs, and version information into binary formats usable by Windows executables.
The tool supports three formats: "rc" (text resource scripts), "res" (binary resource files), and "coff" (object files for linking). Typical workflow involves compiling .rc files to COFF objects, then linking them with the application.
For cross-compilation from Linux to Windows, windres is typically used as part of the MinGW-w64 toolchain with architecture-specific prefixes (e.g., x86_64-w64-mingw32-windres for 64-bit Windows targets).
Resource scripts are preprocessed by gcc before compilation, allowing use of #include and #define directives.

PARAMETERS

-i file, --input file

Input file name. Without this, uses first non-option argument.
-o file, --output file
Output file name.
-I format, --input-format format
Input format: rc (resource script), res (binary), coff (object).
-O format, --output-format format
Output format: rc, res, or coff.
-F target, --target target
Specify BFD target format for COFF output.
--include-dir dir
Add directory to search path for included files.
-D sym[=val], --define sym[=val]
Define preprocessor symbol.
-U sym, --undefine sym
Undefine preprocessor symbol.
--preprocessor prog
Preprocessor program to use. Default is gcc.
--preprocessor-arg arg
Additional argument for preprocessor.
-v, --verbose
Enable verbose mode.
--help
Display help message.
--version
Display version information.

CAVEATS

Resource script syntax follows Microsoft conventions but may have minor compatibility differences. Some complex resources may require adjustments when moving from Microsoft's rc.exe. The tool is primarily useful for Windows cross-compilation; native Windows development typically uses Microsoft tools.

HISTORY

windres was developed as part of GNU Binutils to provide a free alternative to Microsoft's Resource Compiler (rc.exe). It has been part of the MinGW and MinGW-w64 toolchains since the late 1990s, enabling Windows application development on Unix-like systems. The tool continues to be maintained as part of the Binutils project.

SEE ALSO

gcc(1), ld(1), objcopy(1), objdump(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community