0

Suppose that we have test.dll which in fact consists of several static libraries foo.lib, bar.lib (they were written in c/c++ and generated by msvc and have pe/coff formats). I want to add functions from foo.lib, bar.lib to export table of test.dll. One of ways to export funcion is declspec(dllexport) specifier. But unfortunately it does not work for static library (because object files cannot have .edata section and linked dynamically). After compilation and linking we have test.dll which does not export functions at all. How can I solve this puzzle?

I did some research and I found out that usage of def file can solve this problem. But as I understand I should manually get list of mangled function names from foo.lib, bar.lib and insert the list to def file. It seems like hard way for me, maybe there is better solution?

Alex Aparin
  • 4,393
  • 5
  • 25
  • 51

1 Answers1

0

There's a very similar question about regenerating the DEF file from a DLL. Since dumpbin also understands .LIB files, the top answer should also work for you.

This is an automated process, so it will export everything, even stuff that's not really necessary.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • How does dumpbin find exported functions from lib? object files don't have edata section - I doubt that way will work (I'll checkout it) – Alex Aparin Apr 26 '21 at 11:07
  • @LmTinyToon: A `.lib` does not make a difference between exported and non-exported functions, so the question does not really make sense. `dumpbin` finds **all** functions, which is why I warn that this method will find and then **export all functions** – MSalters Apr 26 '21 at 11:25