Sign in to follow this  
superninja

VC++6 generated .DLL with VS2005/8

Recommended Posts

Forgive me if this is a dumb question, but is it possible to use a DLL generated by Visual C++ 6 in later versions of Visual Studio, especially VS2005 or VS2008? I know that the runtime has changed. The original DLLs are linked against the multithreaded DLL runtime. Would there be any issues? The reason I ask is that for example, I notice that the SDL libraries have two versions, on for use with VS6 and one for VS2005+. In the meantime, I have been using an image library built with VS6 in my VS2005 project. I haven't had a problem with it so far -- is this a fluke?

Share this post


Link to post
Share on other sites
C++ doesn't specify any kind of binary interface - including, but certainly not limited to, how names are mangled. An upshot from this is that C++ DLLs aren't portable between compilers, or even the same compiler with different compilation settings.

Given that you're using two Microsoft products, it's possible that they'll work together - but I wouldn't rely on it - especially if you're passing class instances across the DLL boundry.

Share this post


Link to post
Share on other sites
Got it. Well the library I'm using is a C library, not C++. So all the calls are extern "C" -- I suppose that's the reason why it continues to work.

But I'm still concerned that the DLL references msvcrt.dll while my executable references msvcr80.dll -- something tells me this can lead to a conflict. Won't any calls made to the C runtime library from within the DLL execute code from msvcrt.dll, while calls made to the C runtime library from within my program will execute code from mvcr80.dll?

Share this post


Link to post
Share on other sites
Quote:
Original post by superninja
Got it. Well the library I'm using is a C library, not C++. So all the calls are extern "C" -- I suppose that's the reason why it continues to work.

But I'm still concerned that the DLL references msvcrt.dll while my executable references msvcr80.dll -- something tells me this can lead to a conflict. Won't any calls made to the C runtime library from within the DLL execute code from msvcrt.dll, while calls made to the C runtime library from within my program will execute code from mvcr80.dll?


C functions don't use name mangling, so that's probably why it works. As for the CRT versions...yeah, you'll be using different versions of the CRT. This means that you'll each be using different heaps, so you won't be able to free memory that was malloc'ed in the DLL and vice versa.

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP

C functions don't use name mangling, so that's probably why it works. As for the CRT versions...yeah, you'll be using different versions of the CRT. This means that you'll each be using different heaps, so you won't be able to free memory that was malloc'ed in the DLL and vice versa.


Yuck! Well hopefully I can find the source of the DLL and build it in VS2005 myself.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this