Clone wiki

lrc / Compiler

The Linux Resource Compiler lrc

The compiler is called and therefore invoked simply by lrc. It needs at least one argument: The .rc or the .rif file. In this file, all files that should be compiled to one resource file are listed.

The .rc file format

The .rc file has a simple format:

  • Empty lines are ignored
  • Lines beginning with # are ignored
  • Every other line should have the following format:
ResourceIdentifier   "ResourceFile"   Compression   Encryption   "Password"

The ResourceIdentifier is an alphanumeric string, at most 79 characters long. As the name suggests it identifies the resource within the final resource file and should therefore be unique. lrc prints out a warning if it finds the same identifier more than once. The identifier is case sensitive.

The ResourceFile is the file that contains the actual resource. It has to be in double quotes to avoid problems with spaces in the file name.

Compression defines the compression that is used to compress this resource in the final resource file. At the moment the following compression methods are available:

  • None No compression at all
  • zLib Use zLib compression
  • bzip2 Use bzip 2 compression

Encryption: The encryption option allows the user to encrypt the resource in the final resource file. At the moment the following encryption algorithms are available:

  • None No encryption
  • Serpent Encrypt with Serpent algorithm

Password: The password if an encryption other than None is selected. Spaces are allowed and therefore it has to be in double quotes. If the first character of the password is a '@' the rest of the password string will be interpreted as filename. In this case the file will be loaded and the content of the file will be taken as password to encrypt the resource. Use this method if you want to use other characters than alphanumeric ones.

The last three parameters (Compression, Encryption and the Password) are optional. If they are omitted, None is taken as default (and therefore no password is needed).

Encoding of the .rc file

lrc does not make any assumptions about the encoding of the .rc file. The best solution is to have the same encoding of the file as the encoding of the file system. Even better is to use only ASCII characters.

The .rif file format

The .rif file has an XML format. The name of the root node is Resources. So an empty .rif file looks like this:

<?xml version="1.0" encoding="UTF-8">

The Resources node has 1 or more child nodes named Resource (the root node is plural, the child node singular).

The Resource node content is the filename of the file to be used as resource. It also contains the following attributes:

  • id
  • compression
  • encryption
  • password

The id attribute is mandatory and defines the resource identifier for the resource. All other attributes are optional. They have the same meaning as the corresponding entries in the .rc file.

An example .rif file

<?xml version="1.0" encoding="UTF-8">
	<Resource id="LINUX-LOGO">data/tux.png</Resource>
	<Resource id="FREEBSD-LOGO" compression="zLib">data/freebsd-devil.png</Resource>
	<Resource id="WINDOWS-LOGO" compression="bzip2" encryption="Serpent" password="secret">data/Windows Logo.png</Resource>
	<Resource id="APPLE-LOGO" encryption="Serpent" password="@pwdFile.txt">data/apple.png</Resource>

Compiler switches

lrc [-d] [-m] [-o <outfile.rdf>] [-c <compression type>] [-e <encryption type> -p <password>] <rcfile.rc>|<riffile.rif>

-d Deny overwriting. If this switch is set an existing .rdf file will not be overwritten, but the compiler exits with an error message. The default is overwriting allowed.

-m Prepare data for direct linking. After the compiler is done, there is one additional file called <file>.o. This file has to be added for linking. The start and end pointer of the data that will be needed will be stored in the external label _binary_<file>_rdf_start and _binary_<file>_rdf_end. See the example ShowEmbeddedImage.cxx how this is done.

-o <outfile.rdf> Generated final resource file. With the -o parameter the user can provide an output file name for the Resource Data File (rdf). If this switch is omitted, the name of the input file is taken, but the file extension is changed to .rdf.

-c <compression type> Compress the whole .rdf file with the given compression type. The same compression types as for single resources are allowed.

-e <encryption type> -p <password> Encrypt the whole .rdf file with the given encryption type and the given password. The same rules apply for the encryption type and password as for single resources.

<rcfile.rc> Input file with the .rc format described above. This parameter (or a .rif file) is mandatory.

<riffile.rif> Input file with the XML format described above. This parameter (or a .rc file) is mandatory.

Compiler output

In case everything went fine, the compiler will (in the long tradition of Unix utilities) give no output.

If anything is not correct or even completely wrong the compiler output will warn you like that:

<file>:<line>:<column>: warning: <Warning cause>

The compiler will not stop due to a warning. It stops only because of an error which will look as follows:

<file>:<line>:<column>: error: <Error cause>