How to compile DLL into project so DLL not needed
Is it possible to compile an existing DLL into your project so that all of its code is embedded into your app? That way you don't have to bundle the dll with the app anymore.
Author Freeworld3Dhttp://www.freeworld3d.org
No.
Mainly because DLLs have a DLL_Main function called when the DLL is loaded/unloaded which could affect the way the DLL works. Including the code (if that were possible) would mean the DLL_Main wouldn't be called, or you'd have to call it the way the OS would have called it. Things get more complex when you look into the way the DLL is loaded in the first place (code fixups, etc).
If you've got a real problem with this, store the DLL as a binary resource and then at program start up, load the resource and save as a file, use LoadLibrary/GetProcAddress to access the DLL and then delete it on program exit. You lose a lot of the conveniance of using DLLs though.
To be honest, I don't think anyone will be bothered if you have a DLL with your executable.
Skizz
Mainly because DLLs have a DLL_Main function called when the DLL is loaded/unloaded which could affect the way the DLL works. Including the code (if that were possible) would mean the DLL_Main wouldn't be called, or you'd have to call it the way the OS would have called it. Things get more complex when you look into the way the DLL is loaded in the first place (code fixups, etc).
If you've got a real problem with this, store the DLL as a binary resource and then at program start up, load the resource and save as a file, use LoadLibrary/GetProcAddress to access the DLL and then delete it on program exit. You lose a lot of the conveniance of using DLLs though.
To be honest, I don't think anyone will be bothered if you have a DLL with your executable.
Skizz
The only reason I had wanted to do it was because I wrote a C# Wrapper for a C++ DLL, which I then put into a DLL itself. I Then call the C# DLL from another C# app. So instead of having to distribute the C++ DLL and the C# one, I just wanted a single DLL. But I guess its not possible.
Author Freeworld3Dhttp://www.freeworld3d.org
Look at: http://www.molebox.com
This small program allows you to pack the EXE and DLL in a single EXE file. You can also pack your resources. The only thing you are not allowed to pack is any file that will change (the final EXE is read only). Its an amazing program... check it.
Luck!
Guimo
This small program allows you to pack the EXE and DLL in a single EXE file. You can also pack your resources. The only thing you are not allowed to pack is any file that will change (the final EXE is read only). Its an amazing program... check it.
Luck!
Guimo
If the DLL writer intended you to use it statically, he would have provided a .lib file, appropriately called a 'static link library'. If you have access to such a binary then you can adjust your project settings to statically link it (so it becomes part of your exe naturally). Otherwise, you'll have to use one of the hacks described above.
Regards
Admiral
Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Quote:
If the DLL writer intended you to use it statically, he would have provided a .lib file, appropriately called a 'static link library'. If you have access to such a binary then you can adjust your project settings to statically link it (so it becomes part of your exe naturally). Otherwise, you'll have to use one of the hacks described above.
Except that C# (which the OP uses) doesn't really let you create .lib files, so it's actually a fair enough question. [wink]
I've been wondering the same (mostly because at work we've been factoring our code out into a bunch of smaller projects, each compiled to a dll. Only problem is that on PDA's, you don't want to have too many dll's loaded, so being able to put code in a separate project, and then link it into the main .exe would be really handy. (And yeah, in C++, a plain .lib file would solve the problem, but VS doesn't let you make those for C#.
In delphi / pascal, you can use this, which will turn the dll into pascal unit with declared binary data for the dll contents. there is code in the unit which will map it into memory, relocate, and gives you getprocaddress functionality to the dll's calls, which work perfectly.
http://www.basegraph.com/bg/tutorials/eng_tutor_dlltools/dlltools.html
http://www.basegraph.com/bg/tutorials/eng_tutor_dlltools/dlltools.html
Projects: Top Down City: http://mathpudding.com/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement