3.2. Compiling resource files: WRC

To compile resources you should use the Wine Resource Compiler, wrc for short, which produces a binary .res file. This resource file is then used by winebuild when compiling the spec file (see The Spec file).

Again the makefiles generated by winemaker take care of this for you. But if you were to write your own makefile you would put something like the following:

WRC=$(WINE_DIR)/tools/wrc/wrc

WINELIB_FLAGS = -I$(WINE_DIR)/include -DWINELIB -D_REENTRANT
WRCFLAGS      = -r -L

.SUFFIXES: .rc .res

.rc.res:
	$(WRC) $(WRCFLAGS) $(WINELIB_FLAGS) -o $@ $<
      

There are two issues you are likely to encounter with resource files.

The first problem is with the C library headers. WRC does not know where these headers are located. So if an RC file, of a file it includes, references such a header you will get a 'file not found' error from wrc. Here are a few ways to deal with this:

The second problem is that the headers may contain constructs that WRC fails to understand. A typical example is a function which return a 'const' type. WRC expects a function to be two identifiers followed by an opening parenthesis. With the const this is three identifiers followed by a parenthesis and thus WRC is confused (note: WRC should in fact ignore all this like the windows resource compiler does). The current work-around is to enclose offending statement(s) in an #ifndef RC_INVOKED.

Using GIF files in resources is problematic. For best results, convert them to BMP and change your .res file.

If you use common controls/dialogs in your resource files, you will need to add #include <commctrl.h> after the #include <windows.h> line, so that wrc knows the values of control specific flags.