Libraries and compiler compatibility on Windows

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Libraries and compiler compatibility on Windows

  1. #1
    Join Date
    Nov 2005

    Question Libraries and compiler compatibility on Windows


    I have an application built on VS2005 which uses a static library built using VS6.0.

    I have noticed an issue of incorrect function getting called from a static library linked at compiled time. Note that this static library was built using Visual Studio 6.0. Whereas my application which is using the static library for linking at compile time is built using VS2005.

    At run time, I see that incorrect/different functions are getting called rather than the ones which are supposed to get called.

    To solve this issue:
    I rebuilt the static library (.lib) using VS2005. Then this newly built static library was used for compilation along with my application on VS2005. Then the functions are getting called correctly.

    I have 2 questions here:

    1) This means that if there is any static library built with older version of VS6.0, then it will not work correctly with an application built with VS2005. We need to rebuild it with the same compiler as the application is built with. Is this true? why this happens in case of static libraries?

    2) If above point-1 is true, then isn't it necessary to rebuild DDLs also with VS2005? If no, then why it is ok that a DLL built with older version of compiler works fine with application built with newer compiler version?

  2. #2
    Join Date
    Nov 2003
    The answer to your first question is positive. You need to compile and *link* every static library the same compiler and linker's major version. There have been several significant ABI changes since Visual C++ 5.6 so the binaries that that compiler produced will not be compatible with those that VS2005 produces. Needless to say, the linkage will also fail in such cases.
    With respect to DLLs, the secret lies in the fact that the linkage takes place at runtime. It's as if you are linking the same library (DLL) into your main() every time the DLL is loaded. However, since the DLLs themselves contain outdated ABIs, you need to recompile them to avoid unexpected behavior. C++ has changed a lot since the time of Visual C++ 5.6 and some of these changes dictated ABI changes as well (new datatypes have been added, namespaces etc.).
    Danny Kalev

Similar Threads

  1. Replies: 0
    Last Post: 09-12-2007, 07:50 AM
  2. Replies: 1
    Last Post: 03-07-2007, 08:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center