Search code examples
visual-c++dllstatic-librariesdllexportdeclspec

Stopping dllexport functions in .lib from getting exported from a DLL


I've got a copy of the axtls library that I've compiled into a static library. I'm linking it into a DLL that I'm building, and some of the axtls functions (_MD5_Final, _MD5_Init and _MD5_Update) seem to be getting exported from my DLL. I'm trying to figure out how to stop that from happening.

My DLL is built with a .def file that doesn't list any of these functions. However, they are all declared as __declspec(dllexport) in axtls itself so I suspect that is why they're being exported.

I was wondering if there was a way to block export of these functions, using a .def file or similar? My DLL is going to be used as part of a public SDK, so it's not particularly good to be exposing internal functions like this.

I suspect removing the __declspec(dllexport) from the definitions in axtls might solve my problem, but I'd rather not go modifying upstream code if I can avoid it.


Solution

  • Whenever you have a static LIB file and see all it's exported functions in a DLL that uses this LIB file to build, the solution is simple:

    Recompile the static LIB project without __declspec(dllexport) and then recompile the DLL project.

    With a DEF file you cannot do that.