I have a C library, which I build as a shared object for Linux and a DLL for Windows with MinGW32. The API depends on a couple of data files (statistical models) which I'd really like to roll in with the SO/DLL so that deployment is just one file.
It looks like I can achieve this for Windows with a "resource file" compiled with windres
, but then I've got to write a bunch of resource-handling code for Windows, and I'm still stuck with the files on Linux.
Is there a way to achieve the same functionality on Linux?
Even better, is there a portable solution?
fopen
andfread
simply won't work on blocks of memory, at least not on any system I'm aware of.stringstream
from the binary data and then it acts like an file anyway. It's also worth noting that with avr-libc (and probably other libcs targeted at microcontrollers) you actually can makefread()
work on arbitary blocks of memory (or anything else) by supplying your owngetc()
andputc()
via function pointers to thefdevopen()
function (fopen()
doesn't make much sense without an OS, much less a file system).