Java SWIG unsatisfiedlinkerroe ClassJNI.method()J

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Java SWIG unsatisfiedlinkerroe ClassJNI.method()J

PiMac
This post has NOT been accepted by the mailing list yet.
Hello,

I have been trying to use SWIG in my project. It seems that I am missing something. Please help. What I have done so far:
http://web.mit.edu/svn/src/swig-1.3.25/Examples/java/class/index.html - using this tutorial

1. created a header Header.h with Visual Studio
#pragma once

class Test {
public:
        Test();
        ~Test();
        void showNumber();
private:
        int number;
};

2.created swig interface
/* File : Header.i */
%module Header

%{
#include "Header.h"
%}

/* Let's just grab the original header file here */
%include "Header.h"

3.In CMD run:
swig -c++ -java Header.i

4.Created SwigTest3.cpp
#include "Header.h"
#include <iostream>
Test::Test() {
        number = 12;
}
Test::~Test() {
}
void Test::showNumber() {
        std::cout << "Number: " << number << std::endl;
}

5. Created 64 dll from cpp & h files with Visual Studio

6. Created Java main.java class
public class main{
        static{
                try {
        System.load("E:\\C++ projects\\SwigTest3\\SwigTest3\\SwigTest3.dll");
                } catch (UnsatisfiedLinkError e) {
                System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
                System.exit(1);
                }
               
        }
        public static void main(String argv[]){
                System.out.println("Hello");
                Test te = new Test();
        }
}

7. Running main.java gives me
Hello
Exception in thread "main" java.lang.UnsatisfiedLinkError: HeaderJNI.new_Test()J
        at HeaderJNI.new_Test(Native Method)
        at Test.<init>(Test.java:38)
        at main.main(main.java:13)

Please tell me what am I doing wrong.
Loading...