SYNOPSIS
rc [ options ] <data file> [data file]...
DESCRIPTION
rc is the resource compiler. The resource compiler is a
tool that takes as input binary files and generates as
output an object file containing each binary file as a
resource that can be linked using the GNU linker `ld'.
A resource is a pair of symbols (variables) in an exe
cutable or relocatable object file. The first symbol is an
array of bytes containing data the program uses, and the
second is an integer containing the size of the first sym
bol. Resources provide a method of easily using binary
data within C programs, and of flexibly changing this data
after compilation.
The name of the symbols are determined by the input file
name, unless the -s ot -l options are used. The first
symbol (the data variable, known as the `data symbol') is
named the same as the file, less the path and everything
past the first `.'. The second symbol (known as the
`length symbol') is named the same as the first, with
`_len' appended.
To use the symbols in the object file, simply link the
object file to your compiled files, referring to the sym
bols as externals.
OPTIONS
-g Generate a header file with the specified name
which can be included to define the symbols in the
created object file.
-h Show help
-l Specify a length symbol name. One -l option per
file being compiled may be specified, each -l
option corresponding by order to a file. If there
are more files than -l options, the files with no
-l option are given length symbols with names as
above.
-o Choose output filename for new ELF executable
-s Specify a data symbol name. One -s option per
filename may be specified, each -s option corre
sponding by order to a file. If there are more
files than -s options, the files with no -s option
are given symbols with names as described above.
Unless the -l option is specified the length symbol
extern char icon[]
extern int icon_len
...
And then links with the resource object file:
gcc dump_img.c icon.o
2. This next example compiles the files snd1.mp3 and
snd2.mp3 into sounds.o, creating the symbols snd1,
snd1_len, snd2, snd2_len in the object file:
$ rc -o sounds.o snd1.mp3 snd2.mp3
3. This next example compiles the files snd1.mp3,
snd2.mp3, and snd3.mp3 into sounds.o. snd1.mp3 will have
data symbol `laugh' and length symbol `laughSize',
snd2.mp3 will have data symbol `cry' and length symbol
`cry_len', snd3.mp3 will have data symbol `snd3' and
length symbol `snd_len'. This demonstrates the usage of
the -s and -l options, and what occurs if there are not
enough -s or -l options.
$ rc -o sounds.o -s laugh -l laughSize -s cry snd1.mp3
snd2.mp3 snd3.mp3
4. The following example creates an object file named
icon.o from the binary file icon.png, and generates a C
header file that can be used in a C program to refer to
the resources:
$ rc -g res.h -o icon.o icon.png
This header file can be used by a C program if it adds
lines such as the following, and links with icon.o:
...
#include "res.h"
...
AUTHOR
Written by Jeff Williams <minimalism@somaradio.ca>
REPORTING BUGS
Report bugs to <minimalism@somaradio.ca>.
SEE ALSO
rc(1), gcc(1), ld(1), objcopy(1), objdump(1), readelf(1),
and elf(5).
Man(1) output converted with
man2html