Mafahir Fairoze
Mafahir Fairoze

Reputation: 697

Accessing C++ native DLL (with namespaces) through JAVA

I have a c++ DLL where the functions are nested within namespaces.

I need to access these functions in java.. i'm not much of a java expert but i do know a little of its basics.

I found basic java codes to access methods in C++ native DLL using JNI but im not sure how to access the functions nested within namespaces.

Upvotes: 0

Views: 1654

Answers (3)

zOlive
zOlive

Reputation: 1778

Do yourself a favour : use BridJ for C++ interop, it should be able to deal with most namespace issues :-)

(disclaimer : I'm BridJ's author)

Upvotes: 1

umlcat
umlcat

Reputation: 4143

"Jeremiah Willcock" answer is right, in any case, you can always access a D.L.L. functions, inside classes or namespaces using "mangled names", its the weird, dirty way of doing things, but, its works, even if there are other ways.

You could do some tests, accesign those functions, and later, make your own wrapper.

Upvotes: 0

Jeremiah Willcock
Jeremiah Willcock

Reputation: 30969

You will probably need to get the mangled names of the C++ functions. You can use nm to do that on Unix or dumpbin /exports on Windows. The mangled name will have the namespace and function name, so it should be easy to find (unless there are several overloads with the same name that you need to distinguish). Are you sure the functions are normal C++ functions and not class methods?

Upvotes: 1

Related Questions