Graphisoft Resource Compiler

In this example, we will create a native binary Windows resource for an Example dialog, which contains few icons, a picture, text items and two buttons:

Example Dialog ScreenShot

The resource files corresponding to this dialog are:

  • ExampleGRC.grc: this GRC file contains the localizable resources ('GDLG' and 'DLGH')
  • ExampleFixGRC.grc: this GRC file contains the non-localizable resources ('GICN')
  • Example.rc2: Windows resource descriptor file to join the localizable and non-localizable resources together

The result will be a Windows resource file (.res), which contains the native image resources and the dialog resources:

Example.res Opened in Visual Studio 2015 ScreenShot

Note that the Resource Compiler can handle only one input file per one run.

We compile the resources in three steps. Later, every step is thoroughly explained:

  1. Step: Compile the non-localizable GRC file with ResConv tool
    ResConv.exe -m r -t W -q utf8 1252 -d WINDOWS -p .\RFIX\Images -i .\RFIX\ExampleFixGRC.grc -o .\RO\ExampleFixGRC.grc.rc2
  2. Step: Compile the localizable GRC file with ResConv tool
    ResConv.exe -m r -t W -q utf8 1252 -d WINDOWS -i .\RINT\ExampleGRC.grc -o .\RO\ExampleGRC.grc.rc2
  3. Step: Compile .rc2 file using Windows Resource Compiler (RC)
    rc.exe -I .\Src -I .\RO -Fo.\RO\ExampleGRC.res .\\Example.rc2

Every command should be typed as a single line into the command line.

  1. Step

    In this step the native Windows .rc2 resource descriptor file is translated from the non-localizable GRC file and image conversions take place. From the information in the GRC file and the image sources, ResConv creates native Windows resource files (.ico, .cur, etc.).

    API version 20 The possible source image formats of an icon resource are PNG and SVG. For further information, read how to compile icon resources.

    The first parameter (-m r) specifies the converter operation mode of the ResConv (-m r is the default, so you may omit that). The second option is important, we instruct the compiler to convert to Windows platform, so it knows that it should generate native resources and a native resource descriptor file, as mentioned the paragraph above. We could add the output codepage and some #define’s also. The -p parameter defines the path to the source images. And finally the last two parameters specify the input and the output files.

  2. Step

    In this step the native Windows .rc2 resource descriptor file is translated from the localizable GRC file.

    Parameters are the same as described in the first step, but here no need to define the path of the images.

  3. Step

    This step is for completeness. We should further compile the output of the previous steps into a native Windows .res file with the Microsoft Resource Compiler (rc.exe). Example.rc2 joins the output of the previous steps together.

    For the explanation of the parameters, see the details for RC in MSDN.

We are ready!

We can integrate these steps into a batch file. The various file names, directories and defined parameters can be parameters for this batch file too. The process can be also be summarized in a .msc Windows makefile, and then can be executed by NMAKE. nmake will automatically watch for the changes of the files, and will only take the necessary steps to build the resources.