Reputation: 98505
I'm linking my executable with a third-party static library that was compiled with wrong defines passed to the C compiler. The same library is also available as a DLL, and the static version was compiled such that all of the symbols are exported. This of course makes no sense for a static library, since the exports propagate to the executable (or a DLL) such a library would be integrated into.
When I link the executable with this library, the symbols from the library are exported from the executable. I'm not concerned about the generated .lib and .exp files. I need to get rid of the exported symbols in the executable itself.
What I need is a way to either:
Force the linker's list of exported symbols to be cleared, or
Edit the object files extracted from the library to "unexport" the symbols.
I'm using Visual Studio 2012 to build the project. The library is provided as a .LIB file, and I can use the librarian to extract the object files and dumpbin to confirm presence of exported symbols.
At the moment I don't want to bother the vendor to fix it, or rather, I don't expect them to reply before I grow old.
Upvotes: 2
Views: 3149
Reputation: 98505
To completely override the symbols that are exported from a PE image (.exe or .dll) created during linking, one has to link with an .exp
file. Merely linking with a .def
file can only add symbols to the exported list, not remove from it.
Create a .def
file. If you don't want to export anything, it will be almost-empty:
NAME "YourExecutableBaseName"
This would be for YourExecutableBaseName.exe
or YourExecutableBaseName.dll
. The basename in the .def
should match the linker's output file name, otherwise there will be a warning.
Create an .exp
file from the .def
file using LIB
.
Link the executable with this .exp
file. This exports file completely defines any and all exported symbols, and the linker will not export anything that's not there.
Upvotes: 2