Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include all dll's in exe?

I have a Visual Studio 12 project; source code written in C++; it's an OpenCV project. I want to give my compiled program to someone else, but, on other PC, I getting an error message about missing some dlls. My program using many OpenCV (maybe, not only) dll's. How can I resolve that problem? Maybe in VS 12 available an option to include all dll's in .exe? It's a pretty similar question without proper answer: include dlls in visual studio c++ 2008

like image 312
Pavlo Zvarych Avatar asked May 24 '14 12:05

Pavlo Zvarych


People also ask

Can an EXE be a DLL?

You can choose between creating an EXE or a DLL when writing Dot NET code. Both of these include executable code, however, DLL and EXE operate differently from one another. The EXE will create its own thread and reserve resources for it if you run it.

Can a exe link to DLL and static library at the same time?

Yes, the Core and Utils code will be duplicated. Instead of building them as static libs you can build them as dlls and use anywhere. Save this answer.


1 Answers

DLLs themself can not be "statically linked" into an executable; that completely defies their purpose (well, actually you can use some really weird voodoo tricks to actually do it, but this is neither recommendable nor should you try it if you have to ask this question).

The simple solution would be to identify all the DLLs your program requires (just starting the program in the Debugger will generate a log file listing them all) and copy those DLLs into the same directory as the EXE resides in; as it happens the directory with the EXE file in is also the first directory where the system looks for DLLs before advancing to the standard system directories in default configuration. Package it up and distribute it that way.

like image 196
datenwolf Avatar answered Oct 08 '22 22:10

datenwolf