0

I have a .dll I want to statically link to my C++ exe. I have created a header I believe to contain accurate function signatures, so I need to build a lib file from my dll. I use dumpbin to get the names of the functions in the dll, but most functions are nameless and have only ordinals. What should I put in my .def file then?

I have managed to find few batch scripts that create lib file from dll but they just ommit those nameless functions.

An in depth tutorial on lib, def, obj files and linking that goes to the bottom of the matter and is easy to follow would be greatly appreciated from many people I think, although I will be happy to just solve my problem aswell.

I am using Visual C++ Express 2010.

john
  • 3
  • 2
  • Not related to your question, but *why* are you using a compiler that's almost a decade old? Why not get an up-to-date one so you can use modern C++? – Jesper Juhl Nov 09 '18 at 16:33
  • @JesperJuhl Bah, that's nothing! I'm *working* with Borland C++Builder 6.0 which is soon 20 years old. Thank god for legacy systems for workplace security. ;) – Some programmer dude Nov 09 '18 at 16:39
  • You are right it is not related. I don't want to risk starting a comment discussion about that. – john Nov 09 '18 at 16:41
  • 1
    @Someprogrammerdude I wouldn't want your job. Luckily my workplace keeps tools up-to-date, so we've been on C++17 since april. And I'm not going back. – Jesper Juhl Nov 09 '18 at 16:41
  • This can help: https://learn.microsoft.com/en-us/cpp/build/exporting-functions-from-a-dll-by-ordinal-rather-than-by-name?view=vs-2017 and https://learn.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-def-files?view=vs-2017. You can add @X to the function entry where X is the ordinal value of the function (that you can see from dumpbin) – M'hand BOUGHIAS Nov 09 '18 at 16:47
  • This shows that one can export functions as ordinals by applying @ORDINAL NUMBER to the name. The name is what I don't have. In other words I need the opposite - not to hide the name of a function but to give a name to a nameless function... In yet other words I get only ordinal numbers from the dump bin utility for most of the functions and this is my problem – john Nov 09 '18 at 17:12

1 Answers1

2

If the functions are only exported by ordinal (that is each export is decorated with NONAME) then the name doesn't matter you can assign whatever name you like. Of course you better know what each ordinal is supposed to be.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23