locked
Debug DLL with a debug exe not loading RRS feed

  • Question

  • I am fairly new to C++ and making dlls, but right now I am  trying to write a DLL for an executable that is already made, but I'm using the debug source code of it (which is a Visual Studio 6 C++ file) and am trying to run my Debug DLL (Visual Studio 2005), but the exe will only load the exported commands with the release copy of my DLL.  I have all the commands in a .def, and I am fairly new to this, but it makes coding this alot more troublesome when I have to make a release every time.  If anyone has any input at all on this, please post it

    thanks,
    Nate
    Friday, May 30, 2008 8:55 PM

Answers

  • That's expected behavior.  The fact is, you cannot mix DLLs and EXEs that are created using different versions of Visual C++ if you wish to debug them.  In certain cases this is ok for release builds (if not debugging), but for debugging, you must be using the same version of Visual C++ for all components.
    • Marked as answer by Yan-Fei Wei Thursday, June 5, 2008 5:25 AM
    Friday, May 30, 2008 8:59 PM
  • What you are doing isn't supported anyway.
    If you want to mix libraries created with different versions of a compiler you have to follow certain rules. But the easiest way to not have a problem is to just build with the same compiler.
    Going into this too much would just be confusing, but things do change with compiler versions and whats worse, things change between debug and release builds.
    The rules to follow with doing something like this.
    Do not use C++ linkage, when you export your functions from the DLL you should make them extern"C". This will avoid any possible name mangling problems.
    Do not pass allocated memory back and forth. The best thing to do is use accessor functions.
    Remember that objects can change size depending on version and debug/release so know what you are doing.

    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    • Edited by Darran Rowe Friday, May 30, 2008 10:35 PM updated
    • Marked as answer by Yan-Fei Wei Thursday, June 5, 2008 5:25 AM
    Friday, May 30, 2008 10:29 PM

All replies

  • That's expected behavior.  The fact is, you cannot mix DLLs and EXEs that are created using different versions of Visual C++ if you wish to debug them.  In certain cases this is ok for release builds (if not debugging), but for debugging, you must be using the same version of Visual C++ for all components.
    • Marked as answer by Yan-Fei Wei Thursday, June 5, 2008 5:25 AM
    Friday, May 30, 2008 8:59 PM
  • What you are doing isn't supported anyway.
    If you want to mix libraries created with different versions of a compiler you have to follow certain rules. But the easiest way to not have a problem is to just build with the same compiler.
    Going into this too much would just be confusing, but things do change with compiler versions and whats worse, things change between debug and release builds.
    The rules to follow with doing something like this.
    Do not use C++ linkage, when you export your functions from the DLL you should make them extern"C". This will avoid any possible name mangling problems.
    Do not pass allocated memory back and forth. The best thing to do is use accessor functions.
    Remember that objects can change size depending on version and debug/release so know what you are doing.

    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    • Edited by Darran Rowe Friday, May 30, 2008 10:35 PM updated
    • Marked as answer by Yan-Fei Wei Thursday, June 5, 2008 5:25 AM
    Friday, May 30, 2008 10:29 PM
  • I moved everything over to 6.0 and now I can debug, thanks
    Thursday, June 5, 2008 8:03 PM