Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine multiple DLL's into 1

Tags:

c++

dll

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?

like image 254
Greg Treleaven Avatar asked Feb 27 '23 08:02

Greg Treleaven


2 Answers

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.

like image 167
ChrisW Avatar answered Mar 08 '23 09:03

ChrisW


Realistically, no. In theory, if you wanted to badly enough you could do something like disassembling all of them, then re-assembling all the separate files into object files, then re-linking those object files into one big DLL. Getting this to actually work would usually be non-trivial though -- there are likely to be things like conflicting symbol names that would require considerable work to get around.

A rather cleaner possibility would be to package all the DLLs into a zip file (or whatever you prefer) and have a small program to unzip them to a temporary directory, run the main program, and then erase the DLLs from that directory. This has a few problems of its own though (e.g., leaving copies of the files if the machine crashes/loses power/whatever during a run).

Edit: Since you have the source code, using it to build all the code into a single DLL is much more reasonable. For the most part, it's just a matter of adding all the source files to a single project that creates one DLL as its output. You may (easily) run into some symbol conflicts. Given access to the source code, the obvious way to deal with this would be by putting things into namespaces.

like image 29
Jerry Coffin Avatar answered Mar 08 '23 09:03

Jerry Coffin