views:

62

answers:

3

I am trying to figure out a way of embedding a resource into a static library for linking with C source using the gcc toolchain. The equivalent of a Windows DLL in which resources are embedded. Can this be done with a linux static library?

In short, would for example, doing this cat someresourcedata.txt > mylib.a and to be able to link it with a compiled C code that references mylib.a.

Any ideas or suggestions? Thanks, Best regards, Tom.

A: 

If the data can be represented as text, place it into an include file. Here's an example for how to do this with an XPM image:

/* XPM */
static char * my_xpm_image[] = {
"16 16 15 1",
"       c None",
".      c #000000",
"+      c #7FFFFF",
"@      c #007F7F",
....

And then go about the standard way of creating a static lib (whatever that is - I've not done it, only a dynamic lib and I'm a little rusty on that).

James Morris
+2  A: 

Duplicate of http://stackoverflow.com/questions/1997172/

Andrew McGregor
@Andrew: Cheers for the link...saw your answer on the above link to the linuxjournal.com! Thanks a million! +1 from me and accepted! ;)
tommieb75
Not a problem :-)
Andrew McGregor
A: 

*nix does not have the same concept of "resources" that Windows does; they are usually stored as external files, both for executables and libraries.

Ignacio Vazquez-Abrams