I've finally found a turn-around :
As I said before, I have a static library compiled using VC6. This
static library has a C Interface although the implementation is in C++
and takes advantage of many VC6, C++ dlls, uses STL, and has exceptions
disabled.
The trouble is that when linking an executable (VC .Net) with a static
library (VC6), the run-time library loaded by the VC6 static lib is the
VC . Net one. So when the static library exchanges complex data (such as
string object or stl, or template parameters) with the VC6 dll it
crashes even if memory allocation/unallocation policy is done side by
side. This happens because the VC6 dlls have the VC6 runtime library in
memory and because VC6 runtime lib and VC7 rt lib are not compatible on
many points (STL,....). One solution was to turn the static lib compiled
with VC6 in a VC6 dll . As the dll interface is in C, even if both
runtime library have to communicate, it is not a problem. (of course the
more practical solution would be to compile all components using the
same compiler - but for some out of topic reasons I could not do that).
[quoted text, click to view] stephane jaeger wrote:
> I'd like to add some information about my "real life" problem since the
> piece of code of the previous post was just a basic example.
>
> I have a static library compiled using VC6. This static library has a C
> Interface although the implementation is in C++ and takes advantage of
> many VC6, C++ dlls, uses STL, and has exceptions disabled.
>
> In addition to this static library I use the Qt library as a DLL
> compiled using VC6.
>
> I now want to build a simple app using VC .NET that creates a GUI using
> the Qt dll and that makes calls to the static library. Obviously, as the
> static library uses VC6 dlls, I also need to link my executable with the
> corresponding .lib.
> My app compiles and links fine with VC . Net, but crashes ( launches an
> exception) into a static initialization of a string static member of my
> static library. I do not understand why since there are no objects
> exchanged between the app and the static lib since the lib has a simple
> C interface (The fact of having both VC6 and VC .NET rt lib loaded in
> memory shouldn't be a problem in this case ? ).
> If Anybody has some Idea ?
> Bye
> Stephane
>