How to generate 64 bit .dll which gcc compiler or other. Can't load IA 32-bit .dll on a AMD 64-bit platform.

Hi I didn’t find solution how to create 64 bit dll. And use it’s native c++ methods. I use Java code :

    class metodynatywne {
    static {
    native public void sayHello();
    public static void main (String argv[])
        new metodynatywne().sayHello();
    }  }

then generated metodynatywne.h using javah -jni metodynatywne

I wrote metodynatywne.cpp code :

`   #include <jni.h>
   #include <iostream>
   #include "metodynatywne.h"
   using namespace std;

   Java_metodynatywne_sayHello(JNIEnv * env, jobject self)
cout << "Hello World!" << endl;

I ussed gcc to create my dll with comands :

c:>c++ -I c:\java7\include -I c:\java7\include\win32 -c metodynatywne.cpp


c:>c++ -shared metodynatywne.o -o metodynatywne.dll

and what what I'm getting is 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.(

I used Java 1.4 32 bit javac compiler and java7 x64 compiler both metods gave me the same error. How can I deal with that? Use another c++ compiler if yes how force this compiler to create usable by my java dll file. I working on Windows 7 64 bit.

How I can make from cpp file a 64 bit dll (with gcc) ? Or other comand line compiler ?

Thanks in advance for help.

1 Like

I have seen the exact same question here. Is that U who asked the question?? I don’t think so?? What’s the point in copying the same question when it’s already answered?? :slight_smile:

Its Clearly Explained HERE. It might be useful :slight_smile:

Another Discussion :slight_smile:LINK 2

Dude at least google it before asking questions…:slight_smile: