Hi, I did not find a solution how to create a 64 bit dll. And use its native C ++ methods. I am using metodynatywne.java java code:
class metodynatywne { static { System.loadLibrary("metodynatywne"); } native public void sayHello(); public static void main (String argv[]) { new metodynatywne().sayHello(); } }
then the generated metodynatywne.h using javah -jni metodynatywne
I wrote the code metodynatywne.cpp:
#include <jni.h> #include <iostream> #include "metodynatywne.h" using namespace std; JNIEXPORT void JNICALL Java_metodynatywne_sayHello(JNIEnv * env, jobject self) { cout << "Hello World!" << endl; }
I used gcc to create my dll using the commands:
c:\>c++ -I c:\java7\include -I c:\java7\include\win32 -c metodynatywne.cpp
and
c:\>c++ -shared metodynatywne.o -o metodynatywne.dll
and that I get an error message:
c:\>java metodynatywne Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Programowanie\UJ\Semestr2\ZPG\PerfCount\cwiczenie\metodynatywne.dll: Can't lo ad IA 32-bit .dll on a AMD 64-bit platform at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(Unknown Source) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at metodynatywne.<clinit>(metodynatywne.java:4)
I used the Java 1.4 32-bit javac compiler and the java7 x64 compiler, both methods gave me the same error. How can I handle this? Use a different C ++ compiler, if so, how to get this compiler to create a usable java dll file. I am working on Windows 7 64 bit.
How can I make a 64-bit dll (with gcc) from a cpp file? Or another command command?
Thank you very much for any comments and help provided.
source share