Hi, I'm wondering if it's possible to combine multiple DLL's into 1. I'm currently working on a C++ project that is dependent on many dynamic link libraries,so would it be possible to combine them into 1 DLL file, and if so, how would I do that?
+1
A:
Its certainly not infeasible. The Dll format contains all the information you need to merge the code and data from multiple dlls into one, and rebase the resulting code.
this is not a standard feature of any toolchain I can think of though.
Chris Becke
2010-08-29 18:12:25
In the general case this isn't possible really, you'll have a lot of duplicate symbols. Parts of the CRT (all of it if you link it statically) will be in both processes, possibly optimized so it's not exact copies either.
Blindy
2010-08-29 18:29:31
That would be re-linking. There is no name-level operation required to glue two dlls together. all you would do is concatenate, or create duplicate (renamed) .text, .sdata etc sections (the names of these sections are not actually relevent). and then process the relocation table - adjusted for the new base address of the merged sections.symbol names don't enter into it (unless you are trying to fixup debugging info).
Chris Becke
2010-08-29 18:50:02
You also have to clean up the Import Address Tables, if one of the combined DLLs depended on another. You can't depend on yourself. And that _is_ a name-level operation; you have to match imported and exported entries by scope (DLL) and symbol name.
MSalters
2010-08-30 10:08:56
ooo. I admit I didn't consider cross dependencies. There still isnt a name collision though as the names resolve unambiguously to functions in the merged (or external) dlls.
Chris Becke
2010-08-30 10:28:15
This is all moot though. The OP has the source and can (and should (MUST really))) just build a merged dll.
Chris Becke
2010-08-30 10:28:57
+2
A:
I do have the source code for these DLLs, yes.
Just combine all the source files from all the DLL projects into a single DLL project?
And if you have multiple *.def files (one for each project) then combine them into a single *.def file.
ChrisW
2010-08-29 18:18:45