views:

123

answers:

2

Hello,

I have a C++/CLI project in VS 2008 that has a direct dependency on a native C++ library that, in turn, has four additional native C and C++ library dependencies; some of these dependent projects rely on each other as well. I have source code for all of the libraries and can build them all successfully as separate libraries, but instead of having a multitude of assemblies to distribute, I would really like to consolidate all of them into a single dll containing my managed and unmanaged code.

The dependency projects are rather large (~2000 source and header files) so merging them into a 'super-project' is a bit unwieldy. Given some of the blog posts and articles I've read it does seem possible to link them all together; my challenge thus far has been the lack of documentation or first-person accounts of anyone actually trying this.

Is this something that can reasonably be done? If not, what alternatives should I consider? Is there a strategy in the building and/or linking process(es) that needs to be considered?

A: 

I assume since you are talking about separate libraries you mean DLLs. Since you have the source and can build them, you could add a build output of static library. Then all the static libraries would be linked into your final C++/CLI assembly dll.

I've done this quite a bit with native C++ - put the logic into a static library, add a "real" dll for distribution, and a unit test exe for testing. I don't see why the same pattern won't work for C++/CLI.

Justin Rudd
+1  A: 

I don't think this is a particularly trivial thing to do. There certainly isn't some linker switch you can use to magically combine the DLLs into one, so you don't have much choice but to create a new project or projects. There are also a few issues you may encounter, such as namespace collisions and differing compiler directives. You'll also have to merge the entry points for all five DLLs somehow in your final DLL.

Peter Ruderman