I wanted to build a custom zlib DLL that includes the symbol table. I used MinGW and the DLL works correctly and indeed includes the symbol table but it has to be named zlib1.dll in order to work. I want to name it zlib1-debug.dll to distinguish it from the regular stripped version. How can I inform my applications to load the renamed DLL? I don't want to use the LoadLibrary function. I also made a libz-debug.a file from the object files used to create the DLL. When I compile an example program which is supposed to use the new DLL, I pass -lz-debug to the linker. It compiles without errors, but it still wants to load "zlib1.dll" when I run it. I expected it would try to load "z-debug.dll" but apparently that's not how it works.
1 Answers
When you build dynamic library, you usually get at least two files:
- library itself (for example
.dll
or.so
) - export library (for example
.lib
and.a
, respectively)
Then, when you build application or other library, that utilizes it, you need to add .lib
/.a
file to the linker's input (dependencies) list. Now, the thing is, that name of dynamic library file (.dll
/.so
), that is loaded during application start is saved inside export library during linking process - that's how application "knows", which library it should load symbols from. I guess, that you have at least one of following problems:
- you didn't remove old export file from linker input, so old library is requested anyway
- you didn't add new export file to linker input
- you messed something up and ended with renamed export file, that refers to old library anyway
I would suggest you to:
1. Recompile your zlib
with new name (z-debug
) to make sure, that export file refers to the right library file.
2. Rebuild your application (it will only be re-linked), specifying new library name (so it will be linked against library with new name).