Search code examples
dllmingwdllexportmingw32function

How to specify the exact ordinals for dll exports in MinGW?


I'm trying to build a DLL with MinGW and I need to augment the exports it is generating. I need to assign specific ordinal numbers to certain exported functions.

I created a .DEF file, but I can't find the option to tell MinGW linker to use it. Is it even possible?


Solution

  • Turned out to be extremely easy. Simply link together with the .def file like so:

    gcc obj1.o obj2.o obj.def -shared -omylib.dll
    

    All the ordinals can be listed in the .def file (ordinal @0 doesn't work though, causes a crash of ld).

    Example .def file:

    EXPORTS  
       Insert   @1  
       Delete   @2  
       Replace  @3