0
votes

Is there a way for me to name my exported dll functions? When I use a dll export viewer the function names shown are the full declarations. I would like to use the JNA (JNI) to access functions inside the DLL, and the function names need to be a function name not a full declaration. If this is a duplicate please point it out!

1
Does this answer your question? Java Native Access doesn't do C++, right? - Daniel Widdis
@DanielWiddis -- that is for C++ DLLs. OP is asking about C DLLs. - Andy
@Andy OP hasn't actually been clear on exactly what function names are shown. In the context of JNA, the function names are identical, and "full declarations" tend to be C++. - Daniel Widdis
@DanielWiddis -- I was going off of his tags. - Andy
@Andy fair enough, which is why I upvoted your answer. For me, this is similar to other questions I've seen regarding C++ name mangling. We both need more details to really answer the question. - Daniel Widdis

1 Answers

2
votes

It can actually be done with just the __declspec(dllexport) syntax (that is, without a .def file) if you declare the function as extern "C" (or implement it in a C file instead of C++).

extern "C"
{
  __declspec(dllexport) void __stdcall MyFunc(std::string &);
}

Generally much easier than exporting a mangled name with an alias (as you then need to track down the mangled name in order to assign an alias).