Sign in to follow this  

C++/GCC Embedding binary data in executable

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this