simple dll/lib question

  • Thread starter Thread starter Ramsey
  • Start date Start date
R

Ramsey

When I first started my project I was using stl for all the real
processing and managed c++ for all the pretty forms.

But after a while the project became too large to manage. Now I am
thinking of breaking up the project into dlls/lib files but I am
running into the following problems.

My project can be logically broken into 4 groups of code. 2 that use
stl and 2 that use managed c++.

First I wanted to make all the pieces dlls but I ran into the problem
of having to use some sort of COM layer for the groups of code that use
stl.

Second I tried making everything lib files but for some reason I kept
on getting linker errors when trying to convert the managed c++ code
into libs.

Third I tried making the stl code lib files and the managed code dlls
but I got this weird error in the file "objIdl.h" saying that the
IDataObject class is being redefined, but I never included this file or
used that class.

What I really want to know is what has worked for you when organizing a
project that uses stl and managed code.
Any help would be greatly appreciated.
Ramsey
 
Ramsey said:
What I really want to know is what has worked for you when organizing a
project that uses stl and managed code.
Any help would be greatly appreciated.

I've done this successfully. I have general purpose libraries written in
standard C++, which I can use in any unmanaged project, with any
compiler. It uses STL internally. Now I'm using that library inside a
C++/CLI project (managed) with VC++ 2005 Beta 1. The trick is to
recompile the LIB that uses STL inside with managed settings (CLI
support turned on), even though it's not using anything managed inside.
Then make the main application project mixed-mode, because it's not
going to work when it's pure managed. It was a pain to get it to work,
but it all depends on the compiler settings. You must use the same
standard library setting for the LIB and the main app project; which I
think must be Multi-threaded DLL (/MD or /MDd). After that they will be
compatible, and the LIB can be linked to a managed project.

This should also work with DLLs, but again, you must compile a special
DLL with managed extensions turned on. You can't use a DLL compiled
without CLI support. At least not if a DLL is exporting C++ and/or STL
types; because if it's a pure C-interface DLL, it doesn't matter then.

I can help with the project settings if you have problem. There's one
more trick. My mixed-mode application crashed immediately on startup
until I added this to the Linker/Input settings:
Force Symbol References: __DllMainCRTStartup@12
(/INCLUDE:"__DllMainCRTStartup@12" linker option)

Tom
 
Back
Top