Can you embed a .dll into an executable?

wyrd

Well-known member
Joined
Aug 23, 2002
Messages
1,408
Location
California
I was wondering if there was a way to embed user referenced .dlls into your executable, rather than just having it copied to your local bin folder.

Itd be nice to have a single .exe, rather than an .exe + .dlls. :P
 
Im not sure if I follow you. Your saying you have a DLL (a bunch of classes compiled together) that someone else made and want to put in your executable? Dont think that could be done - least not that I can figure, the DLLs would have to be decompiled, added as individual classes to your project and then recompiled with the project to make a single EXE. Now if the DLL was yours then just take the root classes and add them to your project, but I dont think thats what your saying.
 
You can add resources to your project, such as text documents and images. I dont see why a .dll would be any different.
 
Because a dll has to be loaded in to memory, entry points found and all sorts of other issues like that. I see this question a lot and always find myself wondering what benefit a 1mb exe has over a 100k exe and a few dlls?
 
I suppose you could add them as a resource and on execution write them out to disk....
Wouldnt that defeat the point of DLLs - easier updating, better reuse etc?
 
Last edited by a moderator:
Originally posted by divil
Because a dll has to be loaded in to memory, entry points found and all sorts of other issues like that. I see this question a lot and always find myself wondering what benefit a 1mb exe has over a 100k exe and a few dlls?

With small apps, people like a single executable. Makes it easier to share with friends.. and just more convenient.
 
You could create a simple setup program or use Winzip to create a self-extracting EXE. Otherwise, no, theres no way to get a DLL embedded into your EXE without some work.

You could, theoretically, embed the DLL. At runtime you could get the DLL as a resource and write it to disk. Im not sure if that would work 100% or if youd need to also load the DLL yourself. if youre using C++ youre a bit luckier as you can use LoadLibrary to load a standard DLL yourself, though I dont think a .NET managed DLL would work like that.

-ner
 
Surely anyone who wanted a single exe with no dependancies would have chosen the appropriate language and compiler, i.e. MSVC++, to start off with?
 
Originally posted by divil
Surely anyone who wanted a single exe with no dependancies would have chosen the appropriate language and compiler, i.e. MSVC++, to start off with?

Programming in unmanaged C++ just so you could have everything in a single .exe would be nutty.
 
Since thats the only way to do it effectively, its not really nutty. More like "required". :-\ What does this program do, anyway? If its so small, creating it in C++ should be no problem (assuming youre familiar with C++).
 
Back
Top