Visual C++ Developer Center > Visual C++ Forums > Visual C++ General > Using old DLL files built in VS2003 with new projects in VS2008
Ask a questionAsk a question
 

AnswerUsing old DLL files built in VS2003 with new projects in VS2008

  • Thursday, July 02, 2009 1:15 PMSadik AKBULUT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am using some DLL files built with VS2003 in my C++ project. When I was using VS2003 there were no problems. But I've recently upgraded to VS2008 and now I'm getting some linker errors about unresolved external symbols (which are supposed to exist in these DLL files).

    After some search on the internet, I've come up with the following page.
    http://msdn.microsoft.com/en-us/library/tyx5b79y(VS.71).aspx


    This seems to be my problem but with a difference. I cannot rebuild the DLL files which export these symbols. I have to tell the linker to use the correct symbol (old-style) when linking my project to the DLL file.

    I've no chance to rebuild these DLL files with VS2008 and I don't want to downgrade to VS2003.

    Is there any solution (like some linker options) to this problem?

Answers

  • Thursday, July 02, 2009 10:10 PMGiovanni DicanioMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    If you have a DLL with a C++ interface, you should use this DLL only with the same compiler that you used to build it.
    For example, if your DLL has STL classes like std::vector at his interface, std::vector implementation in VC2003 can be different from std::vector implementation in VC2008, so even if the names of these classes are the same, these classes are actually different "guys" (e.g. they could have different internal implementation).

    My first suggestion to you would be to recompile your C++-interface DLL with VS2008.

    If you can't do it (e.g. you don't have the DLL source code), you may want to build a COM wrapper around your VC2003 DLL. COM is a very robust (but complex...) technology to shield against the particular language or compiler you used to build the COM module. e.g. you could use a COM component written in VC6 with VC8!
    So, thanks to a proper COM wrapper around your VC2003 C++ DLL, you could use its functionalities from VC2008.

    HTH,
    Giovanni

All Replies

  • Thursday, July 02, 2009 1:24 PMnobugzMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The article you linked talks about breaking behavior in VS2003 from VS2002.  That cannot match your problem.  Document your problem better, post the linker errors you see and the declarations of the identifiers it is looking for.

    Hans Passant.
  • Thursday, July 02, 2009 10:10 PMGiovanni DicanioMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    If you have a DLL with a C++ interface, you should use this DLL only with the same compiler that you used to build it.
    For example, if your DLL has STL classes like std::vector at his interface, std::vector implementation in VC2003 can be different from std::vector implementation in VC2008, so even if the names of these classes are the same, these classes are actually different "guys" (e.g. they could have different internal implementation).

    My first suggestion to you would be to recompile your C++-interface DLL with VS2008.

    If you can't do it (e.g. you don't have the DLL source code), you may want to build a COM wrapper around your VC2003 DLL. COM is a very robust (but complex...) technology to shield against the particular language or compiler you used to build the COM module. e.g. you could use a COM component written in VC6 with VC8!
    So, thanks to a proper COM wrapper around your VC2003 C++ DLL, you could use its functionalities from VC2008.

    HTH,
    Giovanni