← 返回命令列表

Linux command

windres 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Compile resource script

windres [input.rc] -o [output.o]

Compile to binary resource format

windres -O res [input.rc] -o [output.res]

Convert res file

windres -i [input.res] -o [output.o]

Specify input format

windres -I rc -i [input.rc] -O coff -o [output.o]

Include directory

windres --include-dir=[path/to/includes] [input.rc] -o [output.o]

Define preprocessor symbol

windres -D [SYMBOL=value] [input.rc] -o [output.o]

Cross-compile for 64-bit Windows

x86_64-w64-mingw32-windres [input.rc] -o [output.o]

说明

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.

参数

-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 -E -xc-header -DRC_INVOKED`.
--preprocessor-arg _arg_
Additional argument for preprocessor.
--no-use-temp-file
Use pipes for communication with the preprocessor (default).
--use-temp-file
Use a temporary file for preprocessor communication instead of pipes.
@ _file_
Read command-line options from file.
-v, --verbose
Enable verbose mode.
--help
Display help message.
--version
Display version information.

FAQ

What is the windres command used for?

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.

How do I run a basic windres example?

Run `windres [input.rc] -o [output.o]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -i _file_, --input _file_ do in windres?

Input file name. Without this, uses first non-option argument.