Reputation: 41002
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.
Upvotes: 6
Views: 3893
Reputation: 1176
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.
Upvotes: 1
Reputation: 1246
There's may be a catch, but being in VS2010, you should just click on the startup project, select 'properties' -> 'configuration properties' -> 'general' -> 'configuration type' -> set it to 'dynamic library (dll)'
Upvotes: 0