Wine HQ

  WineHQ Menu
  WineHQ
  AppDB
  Bugzilla
  Wine Wiki
  Wine Forums
  About
  Introduction
  Features
  Screenshots
  Contributing
  News Blog
  World Wine News
  Press
  License
  Download
  Get Wine Now
  Support
  Getting Help
  FAQ
  Documentation
  HowTo
  Live Support Chat
  Paid Support
  Development
  Developers Guide
  Mailing Lists
  GIT
  Sending Patches
  To Do Lists
  Fun Projects
  Janitorial
  Winelib
  Status
  Resources
  WineConf
  Languages
English English
Español Español
  Search WineHQ

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 solution traditionally used by the Winelib headers is to enclose the offending include statement in an #ifndef RC_INVOKED statement where RC_INVOKED is a macro name which is automatically defined by wrc.

  • Alternately you can add one or more -I directive to your wrc command so that it finds you system files. For instance you may add -I/usr/include -I/usr/lib/gcc-lib/i386-linux/2.95.2/include to cater to both C and C++ headers. But this supposes that you know where these header files reside which decreases the portability of your makefiles to other platforms (unless you automatically detect all the necessary directories in the autoconf script).

    Or you could use the C/C++ compiler to perform the preprocessing. To do so, simply modify your makefile as follows:

    .rc.res:
    	$(CC) $(CC_OPTS) -DRC_INVOKED -E -x c $< | $(WRC) -N $(WRCFLAGS) $(WINELIB_FLAGS) -o $@
    
              

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.