I'm doing maintenance on a C++ 6.0 project that uses a .def file to handle function exports. I had to add a pair of instance methods to a class definition, but I don't know how to add these methods to the .def file so they get exported. Each line under the EXPORTS section in the .def file looks something like ?MethodName@ClassName@@AStringOfLetters
with maybe a @Z
tacked on the end for no reason I can fathom. I开发者_运维问答'm assuming the string of letters corresponds in some way to the prototype of the method, but I can't find any documentation that describes the encoding. The methods I added don't have a prototype that exactly matches any of the existing methods.
Let's say my new method prototypes look like this:
short ClassName::Foo1(const short, const unsigned int, const short, const unsigned int *);
short ClassName::Foo2(const short, const unsigned int, short *, unsigned int *);
What do I need to add to the .def file in order to make my linker happy and actually export the methods?
You are exporting the C++ mangled symbols. I would add a __declspec(dllexport)
in front of them temporarily and then load the DLL in something like Dependency Walker, or use dumpbin
to see what is exported. This will give you the mangled symbol for you new functions and then you can add that to the .def file and remove the __declspec
.
To get the mangled name for your new functions, just comment out the implementation and build the project. This way you would get a liker error showing the mangled name of your new function. Update your def file with this new mangled name.
精彩评论