[ale] Resources in executables

Eric Z. Ayers eric.ayers at mindspring.com
Sat Oct 23 23:03:29 EDT 1999


Kalin Nakov writes:
 > 
 > 
 > Hi. I have another Win32-to-UNIX porting question. Are there any standard
 > way (maybe some libraries that can help?) to include resources (like
 > bitmaps, music, binary data) in executables, or I should write them by
 > myself? Such a thing can be very useful when writing a self-extracting
 > executable.

In the case of 'bitmaps', you can include bitmaps as 'xpm' files
directly in your source code.  The xpm library provides a way to
export data suitable for use as a #include (like a a .h file.)  We use 
this for the icons in our programs.



unsigned char arrow_xpm [] = {
0x74,0xef,0,19,0,19,0,3,0,1, /* magic width, height, colors, bytes/color */
0xff,0xff, 0xff,0xff, 0xff,0xff,
0x0,0x0, 0x0,0x0, 0x0,0x0,
0x0,0x0, 0x0,0x0, 0xff,0xff,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,
0,1,2,1,0,0,0,0,0,0,1,2,1,1,0,0,0,0,0,
0,1,2,2,1,1,1,1,1,1,1,2,2,2,1,1,0,0,0,
0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,0,
0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,
0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,0,
0,0,0,1,1,1,1,1,1,1,1,2,2,2,1,1,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,2,1,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};


I can't answer for music and other types of resources.  You can use a
packager like 'rpm' to bundle all the necessary component of your app
together for distribution.

 > And yet another simple thing to ask:
 > What is the directory that usually holds
 > 1. Applications (the equivalent of Program Files in Win32)

/usr/bin is the norm.  or some sites use /usr/local/bin for 'custom'
stuff or add-ons.

 > 2. Application configuration files (the equivalent of where System Registry
 > or INI files are placed)

varies.  SVR4 style is /etc/<appname> or /usr/lib/<appname> is pretty
common. 

 > 3. Application working (documents) directory (the equivalent of My
 > Documents of Win32)

Start in the user's home directory.  Let the user decide how they want 
to structure.  I can never find 'my documents' when I want them on NT
anyway... :-) 






More information about the Ale mailing list