After repeatedly coming across this problem for a couple of years I've today found a solution. It's a little hacky, but it actually might be the best possible way with Visual Studio.
Since you don't want to export EVERY possible symbol (especially since your DLL may include large static libraries itself), and you can't edit the files with symbols you want to have available (for me it's because they're 3rd party libraries which must be statically linked to follow their usage pattern), and DEF is the best solution.
If we have:
- Application (EXE)
- Library (DLL)
- Library has .DEF file which means that when you build, symbols listed in the .DEF will be exported to the Library .DLL and listed in the .LIB file.
- .DEF file is empty
- Application links Library's LIB file
NOW BUILD!
OK, we get a lot of linker errors...
Now go to the "Output" tab, and notice that within the text of the output is the symbol names at the end of each linker error line:
We can create a little script with takes the last 'word' of every line, takes off the brackets, and then put that in your DEF file. And it works!
Like I said it's a little hacky (since you only end up with the symbols used by the Application at that time). But actually since you don't want to export everything, and you might need symbols in the libraries which that library statically links, it's probably the most accurate way of going about this.
(NB : In my case it's mostly a problem with trying to get the plugin DLL have access to symbols in the application EXE)