title: RC short-description: Compiling Windows resources ...

Compiling Windows resources

Since 1.11.0

Meson has support for compiling Windows resource files (.rc). To use it, add rc to your project languages:

project('myapp', 'c', 'rc')

executable('myapp', 'main.c', 'resources.rc')

You can also add the language conditionally, which is useful for cross-compilation setups where an RC compiler may not always be available:

project('myapp', 'c')

if add_languages('rc', required: false, native: false)
  # .rc sources can be used in targets
endif

Compiler detection

The following resource compilers are detected automatically:

Compiler idToolCLI style
rcMicrosoft rc.exeMSVC
llvm-rcLLVM llvm-rcMSVC
windresGNU windresGCC
llvm-windresLLVM llvm-windresGCC
wrcWine wrcGCC

Meson will look for the rc binary in the [binaries] section of your machine file, or through the RC and WINDRES environment variables.

Passing arguments

Extra flags can be passed to the resource compiler using the standard Meson mechanisms:

# Via project arguments
add_project_arguments('-DPROJECT_DEF', language: 'rc')

# Via per-target keyword argument
executable('myapp', 'main.c', 'resources.rc',
           rc_args: ['-DLIB_BUILD'])

The RCFLAGS environment variable is also respected.

Include directories

Include directories work the same as for other languages:

inc = include_directories('res')
executable('myapp', 'main.c', 'resources.rc',
           include_directories: inc)