[SDL] Embed SDL.dll in the .exe

Andre Krause post at andre-krause.net
Mon Oct 1 07:47:13 PDT 2007


Andre de Leiradella wrote:
>> Hey,
>>  
>> If anyone wants to tackle this in Windows, here is what I suggest (thoroughly crazy):
>>  
>> Write a program that extracts all of the necessary files (.exe, .dll, .png, .etc) from _itself_, then runs the main executable that was extracted.  There you go!  So you'll probably have to write a program that creates such a program.
>>  
>> Jonny D
> 
> I did something similar but didn't like the result... I packed everything into one executable. When run, the executable would decompress all DLLs and load them with LoadLibrary. The problems were:
> 
> 1) I had to declare all the functions from the DLLs that I was using to be able to call them (since I wasn't linking the app to the import libraries of the DLLs I had to get their addresses with GetProcAddress).
> 2) Since I was not unpacking another executable, I was having trouble loading the DLLs in the right order. Since the path where they were decompressing was not on the path where Windows looks for DLLs, when I loaded SDL_image.dll, for example, the application stopped complaining it couldn't find SDL.dll. So I had to LoadLibrary them in the right order.
> 
> Unpacking another executable along with the DLLs may solve those problems. Since it will be decompressed in the same path as the DLLs, it will automatically find them when run. No need to use LoadLibrary and get their addresses with GetProcAddress, and Windows will be able to find and load them in the right order.
> 
> This is easy to do, just write a small executable that reads a ZIP attached to the end of the executable, decompress all its contents somewhere, execute the application (an EXE that was decompressed) and, when the app terminates, cleanup everything.
> 
> As I'm in need of such solution, I'll try to code something and release to the list.
> 
> Cheers,
> 
> Andre
> 

this sounds exactly as what this zip2exe software does:

http://www.chilkatsoft.com/ChilkatSfx.asp

why do you want to write your own tool ?
but if you do - let us know. and have a look at

www.experimentalgameplay.com - some of those use the very same technique 
of extracting all stuff and then executing the extracted exe.


> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> 
> 



More information about the SDL mailing list