Jump to content
  • Advertisement
Sign in to follow this  
kimeko

Adding resources to application

This topic is 3867 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

I wanted to add some binary data as a resource in my application. In windows I would use the following code:
#include <windows.h>
HANDLE hExe = GetModuleHandle(NULL);
HRSRC hRes = FindResource(hExe, MAKEINTRESOURCE(IDB_DATA), RT_RCDATA); 
HRSRC hDat = LoadResource(hExe, hRes);
The big problem is that requires windows.h. I can't find any information on loading attached resources in unix. I've successfully compiled my application and linked the resources in to it on my linux box, but I haven't a clue on how to load the data. Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites
Advertisement
I don't think it is customary to include data inside executable
programs on UNIX.

How did you link the resources into the binary? Are you using winelib or
some other cross platform API?

Thank you for your time,
Arrummzen

Share this post


Link to post
Share on other sites
Quote:
Original post by kimeko
I wanted to add some binary data as a resource in my application.

In windows I would use the following code:
#include <windows.h>
HANDLE hExe = GetModuleHandle(NULL);
HRSRC hRes = FindResource(hExe, MAKEINTRESOURCE(IDB_DATA), RT_RCDATA);
HRSRC hDat = LoadResource(hExe, hRes);


The big problem is that requires windows.h. I can't find any information on loading attached resources in unix. I've successfully compiled my application and linked the resources in to it on my linux box, but I haven't a clue on how to load the data.

Any help would be greatly appreciated!


*NIX-like systems don't even share the same "executable" file format: a lot of them will use ELF, but others might use SOM, the old a.out or COFF, etc.

ELF is fairly common nowadays, even on non-*NIX systems (OpenVMS, Playstation, BeOS on x86, ...), but it isn't universal.

This page essentially explains how to embed a file in an ELF binary.

Hope this helps.

EDIT: link added.

[Edited by - let_bound on March 14, 2008 9:17:54 AM]

Share this post


Link to post
Share on other sites
I know about the various formats different operating systems use, I was just told that I could add data to any executable using the .rc format, but that I'd need a different api for each operating system.

Thank you for the link on embedding a file in ELF, very useful.

I've read that I could append my binary to the end of most executable formats without it causing any problems. I think I might do that just so I don't want to worry about how the data is added and retrieved in my code.

Share this post


Link to post
Share on other sites
QT is able to embed resources. (And it's cross-platform!)

It's pretty simple to use.
You add your files to the directory - point at them with an xml-config-file.
And point to the xml-config-file with your project file.

And inside the code you can use them easily via ":/images/bla.jpg" - special notation. I like it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!