prtpacker

Portable Resource Tree Packer

Introduction

prtpacker (pronounced PIRT-Packer) is a tool for creating C or C++
source code from external program resources such as images, text, or
data. These resources can be arranged in a tree structure much like a
typical file system. After compiling and linking the resulting source
code you can access the resource tree from within your software
through a simple API.

Be aware that all resources stay in memory and cannot be easily
deallocated. Generally with small files (< 100K bytes) this is not an
issue. So don't go trying to sticking your latest Divx download in as
a resource. That is unless you want your computer to run like Windows 98.

prtpacker may be ideal for embedded systems where implementing a
complete file system is undesirable. In this case the firmware
footprint may actually decrease.

Pros:

Program resources can't get lost.

Always have the right version with the software.

Increased portability.

Programming convenience.

Quick access.

It is a cheap embedded file system.

Cons:

Larger program memory footprint. (for non-embedded systems)

Must recompile to change resources.

Install

Unpack the source distribution. Then in the resulting directory:

./configure
make
make install

Usage

prtpacker

Create the resource source code.

prtpacker -r myResources resources/* other_resource >resources.cpp

Add a reference to your resources in your code.

#include
extern const prtp_dir *myResources;

Link the result to your program. libprtpacker.a has some useful functions
for accessing prtpacker resources.

g++ -o myapp myapp.cpp resources.cpp -lprtpacker

To access a resource use getResource from prtpacker.h.
Here is an example straight out of prtpacker itself.