Graphisoft®

API Development KitVersion: 18

Graphisoft Resource Compiler Example on Windows


In this example, we will create a resource DLL for an Example dialog, which contains a picture, an icon, and two buttons:

Example Dialog ScreenShot

The corresponding GRC file for this dialog is: ExampleGRC.grc

The result will be a Windows resource DLL file, which contains the native image resources, and the GDLG dialog resource:

Example Dll ScreenShot

Note, that the Resource Compiler can only handle only one input file (.grc) per one run.

We compile the dialog in four steps. Later, every step is thoroughly explained:

1. Step: .\Utils\ResConv.EXE -m d -q utf8 1252 -i .\ExampleProject\ExampleGRC.grc -o .\ExampleProject\ExampleGRC.dep -v PICENVVAR -p .\ExampleProject -d WINDOWS -d DEBUG_VERSION

2. Step: .\Utils\ResConv.EXE -q utf8 1252 -i .\ExampleProject\ExampleGRC.grc -o .\ExampleProject\ExampleGRC.rc2 -t w -p .\ExampleProject -d WINDOWS -d DEBUG_VERSION

3. Step: .\Utils\rc.exe -I .\ExampleProject -r -Fo.\ExampleProject\ExampleGRC.res .\ExampleProject\ExampleGRC.rc2

4. Step: .\Utils\link.exe .\ExampleProject\ExampleGRC.res -DLL -NOENTRY -NOLOGO -NODEFAULTLIB -INCREMENTAL:NO -SUBSYSTEM:windows -MACHINE:IX86 -OUT:.\ExampleProject\ExampleGRC.dll

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

  1. Step

    This is an optional step. When the project is large, and contains many image resources, a dependency can be very useful. The dependency file contains a list from the image resources, with its help the make system can recognize if a resource file (.bmp) has changed despite of the resource descriptor file (image grc) remaining unchanged.

    Let's see the command parameters. First we tell the resource compiler we want to take an action in dependency file generator mode. Then we specify the input and the output files. As we will see, with the environment variable switch we can tell the name of the variable, which will contain the list of the image resource files. We set the destination path, and finally we add some #define's. As a result, we can formulate conditional preprocessor expressions (#if defined ()) in the GRC source with these names too.

  2. Step

    In this step the native Windows .rc2 resource descriptor file is translated from the GRC file and image conversions take place. From the information in the GRC file (eg. transparent color of icons or cursors, hotspot coordinates of cursors) and the .bmp sources, ResConv creates native Windows resource files (.bmp (no change), .ico, .cur, etc.).

    We don't specify the operation mode of the ResConv, because -m r, the converter mode is the default mode. The first two parameters specify the input and the output files. The third option is also 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. As for the previous command, we set the destination path, and finally we add some #define's.

  3. Step

    This step is only mentioned for completeness. If we want to build a resource DLL, we should further compile the output of the previous step into a native Windows .res file with the Microsoft Resource Compiler (rc.exe). For the explanation of the parameters, see the details for RC in MSDN.

  4. Step
    • Input: ExampleGRC.res
    • Output: ExampleGRC.dll

    This step is also mentioned for completeness. If we want to build a resource DLL, we should finally link the output of the previous step into a native Windows .dll file with the Microsoft Linker (link.exe). For the explanation of the parameters, see the details for LINK in MSDN.

We are ready! We can integrate the four steps into a batch file. The various file names, directories and define 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 DLL.