Linux command
glib-compile-resources 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile resources
glib-compile-resources [resources.gresource.xml]
Compile with specific output
glib-compile-resources --target=[resources.gresource] [resources.gresource.xml]
Generate C source code
glib-compile-resources --generate-source --target=[resources.c] [resources.gresource.xml]
Generate C header file
glib-compile-resources --generate-header --target=[resources.h] [resources.gresource.xml]
Specify source directory
glib-compile-resources --sourcedir=[path/to/resources] [resources.gresource.xml]
Print dependencies
glib-compile-resources --generate-dependencies [resources.gresource.xml]
Set C identifier prefix
glib-compile-resources --c-name=[myapp] --generate-source [resources.gresource.xml]
说明
glib-compile-resources compiles application resources (images, UI files, CSS, icons, data) into binary bundles or C source for embedding in GLib/GTK applications. Resources are described in XML files (typically with .gresource.xml extension) that list files to include and optional preprocessing. The GResource system enables applications to access embedded resources through a virtual filesystem path (e.g., /org/myapp/data.txt) without external file dependencies. This simplifies deployment and improves load times.
参数
- --target=_TARGET_
- Output file path. Defaults to basename of input with appropriate extension.
- --sourcedir=_DIR_
- Directory containing resource files referenced in the XML.
- --generate-source
- Generate C source file instead of binary bundle.
- --generate-header
- Generate C header file for use with generated source.
- --generate-dependencies
- Print list of referenced files to stdout.
- --c-name=_PREFIX_
- Prefix for C identifiers in generated code.
- --manual-register
- Generate manual register/unregister functions instead of auto-initialization.
- --internal
- Generate internal symbols (not exported).
FAQ
What is the glib-compile-resources command used for?
glib-compile-resources compiles application resources (images, UI files, CSS, icons, data) into binary bundles or C source for embedding in GLib/GTK applications. Resources are described in XML files (typically with .gresource.xml extension) that list files to include and optional preprocessing. The GResource system enables applications to access embedded resources through a virtual filesystem path (e.g., /org/myapp/data.txt) without external file dependencies. This simplifies deployment and improves load times.
How do I run a basic glib-compile-resources example?
Run `glib-compile-resources [resources.gresource.xml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --target=_TARGET_ do in glib-compile-resources?
Output file path. Defaults to basename of input with appropriate extension.