Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075933 Posts in 44152 Topics- by 36119 Members - Latest Member: Royalhandstudios

December 29, 2014, 04:21:53 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Compressing files into an exe
Pages: [1]
Print
Author Topic: Compressing files into an exe  (Read 1303 times)
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« on: March 12, 2010, 09:28:10 PM »

I did a fair bit of searching. You guys have always been extremely helpful, so I'm back with another question.  Hand Thumbs Up Left

It seems to be common to place files into an .exe. Maybe not an actual file, but the data that the .exe will actually use while running. Although OS X doesn't use .exes, I find that most applications made on it use this technique. I've noticed games like Cave Story do this, and almost all Game Maker games have this.(unless the creator specifically tries to have external resources)

So, my question is: How can I 'pack' files into an .exe? It's something I'd like to know and experiment with.

Details: Language/IDE/Compiler: C++/Code::Blocks/MinGW
Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW Email
« Reply #1 on: March 12, 2010, 10:29:07 PM »

Mac OS X doesn't actually do this (unless you use resource forks, but that's more of an OS 9 compatibility thing).

Mac applications are actually directories.  They behave like executables, but they can be opened by right/control clicking on them and selecting "Show Package Contents," or by simply navigating to them from a command prompt.  A Mac application package contains the actual binary, and a bunch of other things like libraries and icons and whatever other resources you want to put in there.

On Windows, this sort of thing is usually accomplished with resource files.  If you tell me specifically what you're trying to pack, I might be able to tell you how it's done.
Logged

Franchise - The restaurant wars begin!

What would John Carmack do?
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #2 on: March 12, 2010, 11:07:03 PM »

I was hoping to pack my SFML dlls, graphics(all .png), sounds(all .wav), and all my music(probably midi or mp3) into one file, mainly for organizational purposes.

Is there not a way to do a directory system like that of Mac on Windows?
Logged

nikki
Level 10
*****


View Profile Email
« Reply #3 on: March 13, 2010, 05:15:39 AM »

i don't know about mac, but i guess there must be some kind of zip/rar module for you to use, you could stream from a zipped/password secured/ renamed to *.DAT file.

Not only is it nice for orgqanization, it also makes the loading of your data a bit quicker!
Logged
Sos
Level 8
***


[cluck]


View Profile WWW Email
« Reply #4 on: March 13, 2010, 06:12:52 AM »

Your best bet is probably to use WinRAR to create you a silent mode SFX archive that wil extract to temp directory and run your game. you can have it delete it all after it's done.
Logged

Christian Knudsen
Level 10
*****



View Profile WWW Email
« Reply #5 on: March 13, 2010, 06:20:05 AM »

I know of a way to do it in Pascal, but I'm not sure how that would translate to C++. The method here is simply to convert the image/music/whatever file into an array of bytes. This array is then stored in a unit that get compiled along with the rest of your program into the resulting executable. To load one of these images or music files, you just create a memorystream that reads from these arrays. However, the problem with this approach is that all the image/music/whatever file arrays get preloaded into memory on startup as they're part of the executable, which from my experience results in the program taking a lot longer to load (plus all the files will use up memory even when they're not loaded for use).
Logged

Laserbrain Studios
Currently working on Hidden Asset (TIGSource DevLog)
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #6 on: March 13, 2010, 09:01:27 AM »

Disclaimer: I don't know much about this, but I only see worse advice, so here goes.

Windows exes are Portable Executables. They can contain resources (arbitrary data, but frequently images), which are available for the program to read, but are not loaded into memory. These are what you want. There are various tools to pack and unpack them into an exe. Most IDEs let you pack resources, too.

I think how you read them is language dependant. I don't know how.

You may have to extract .dll's before using them, which means you need a writable space on the HD (good to avoid if you can). So if you can statically link the libraries instead of using dlls, I'd do that.
Logged
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW Email
« Reply #7 on: March 13, 2010, 09:12:52 AM »

I was hoping to pack my SFML dlls, graphics(all .png), sounds(all .wav), and all my music(probably midi or mp3) into one file, mainly for organizational purposes.

Windows resource files really aren't meant for most of that, although there may be a way to trick it.  They directly support icons, cursors, menus, dialogs, bitmaps, string tables, accelerator tables, and probably a few other things I'm forgetting.  They all must be accessed through the Windows API, unless you have some kind of wrapper that handles that for you.
Logged

Franchise - The restaurant wars begin!

What would John Carmack do?
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #8 on: March 13, 2010, 10:23:09 AM »

I see!
Oh well. Thanks for all the help, everyone!  Smiley
Logged

genericuser
Guest
« Reply #9 on: March 13, 2010, 12:30:13 PM »

You can also use some (sadly not free) executable packer tools like Molebox or Runtime Packer.
Logged
mjau
Level 3
***



View Profile
« Reply #10 on: March 13, 2010, 01:50:44 PM »

Or just zip up your files and concatenate the zip onto the end of your executable, and use something like zziplib or physfs to have the exe open itself as a zip and read the files.  Works for other OSes too.  Won't work for dlls, but those you can just link statically instead (well, if their license allows)
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic