Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a visual studio 2010 solution into a standalone dll?

I have a visual studio 2010 project, uses static and dynamic libs (.lib and .dll), the project is compiled and built successfully as .exe both in release and debug modes, the code is c and c++.

What is the right way to compile and wrapping all the solution to one standalone .dll file.

I want to have one dll file, I'll be able to load it in other c, c++, c# project safely.

in my case I want to load it in teraterm and in other simple self developed c# application.

like image 768
0x90 Avatar asked Aug 20 '13 03:08

0x90


1 Answers

Visual Studio has a C++ linker option called "Link Library Dependencies": http://msdn.microsoft.com/en-us/library/024awkd1(v=vs.90).aspx

This would link the object files from all projects in the solution directly into the project output (via dependency tracking). Be careful when you use this though, if you use this in an EXE and the DLLs you're linking export symbols your EXE will also export them.

Update:

Here's more detail: What happens is that instead of linking the DLLs (this assumes you have the DLLs you'd like to link set as dependencies of your project in the solution) to produce separate binaries, the linker takes the outputs from each individual project dependency and links them into the final executable/DLL directly, thus creating a monolithic DLL.

A side effect is that (depending on the code) the overall size of the output is reduced a little, the monolithic DLL (or EXE) might be large in general, but smaller in size than the individual output files combined due to link-time optimisations. Any symbols exported by the objects linked will be exported by the final DLL, since they are marked as such in the compilation step.

like image 170
voodooattack Avatar answered Sep 27 '22 17:09

voodooattack