Function decorated names in DLL lib

I've created  a DLL and want the debug build to produce a dll and lib with different name, something like MyLibd.dll and MyLibd.lib (as opposed to MyLib.dll and MyLib.lib).

When I built the debug version of the EXE that uses the DLL in question I obviously linked against the debug version (MyLibd.lib), but noticed that the EXE still loads the release DLL (MyLib.dll). Looking at the debug lib I noticed that all decorated names refer to the release dll (MyFunc@MyClass@@QAEXPDB.MyLib.dll.MyLib.dll), not to the debug dll as they should.

I'm assuming there's a linker setting that determines the dll name, but I just can find it.


Answer this question

Function decorated names in DLL lib

  • Funkjunky

    There is no special linker switch. I use this trick very often. The only thing you have to take care is the output section of the linker. The debug version should append a D for the output DLL and the lib!



  • hz

    Looking at my old projects it turns out I never defined the LIBRARY in the .def file. Having used a VS 2005 template to create the project I'm working on resulted in the LIBRARY being added. If I remove it everything works as it used to. One of those Mondays...
  • new user

    This is what I'm saying. For the debug build I've defined the output file to be MyLibd.dll and the import library to be MyLibd.lib, i.e. both with the 'd' suffix. This is how I've always done it using VC6. The problem is that if I link my exe against MyLibd.lib, it doesn't load MyLibd.dll as it should.

    I noticed a linker warning:

    MyLib.exp : warning LNK4070: /OUT:MyLib.dll directive in .EXP differs from output filename 'Debug/MyLibd.dll'; ignoring directive

    In the MyLib.def if I change the line:

    LIBRARY  "MyLib"

    to

    LIBRARY  "MyLibd"

    it works.

    Don't remember ever doing this in VC6, though. Also, you can only define one .def file per project and I can't use #ifdef in the .def file, so basically I have to modify the .def file every time I want to use a different build. Definitely a step in the wrong direction.

  • Function decorated names in DLL lib