Skip to main content
gamedev.net
🔒 Locked

C++/GCC Embedding binary data in executable

Started by Ilodyn Jan 26, 2006 at 11:19 PM 0 replies 1.3k views
Original Post
Ilodyn
Ilodyn
Hey, how would I go about embedding and using binary data from a file, an image perhaps, into an executable using C++ compiled with GCC? (well MinGW, but I’d like to compile for non-windows platforms as well) I would like to keep my game as a single executable file. Sorry for the short, not so informative post but I don’t have a clue how to do this and therefore I’m not to sure what information I need to provide, if you need any more just ask, thanks.
outRider
outRider
Google 'bin2h' or 'bin2c'. You can find some utilities that will read a file and output a source file that contains your original file as a byte array. That's about the simplest way to do it, but it can slow down your linking if it's a lot of data.


If you want to be Windows-specific, use windres, it's usually part Windows binutils.

I'm sure there are other ways of directly doing it that work for anywhere, and I remember doing it for generating bin images for embedded environments, but I can't remember how it was done.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.