Java SWIG unsatisfiedlinkerroe ClassJNI.method()J

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

Java SWIG unsatisfiedlinkerroe ClassJNI.method()J

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

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: - using this tutorial

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

class Test {
        void showNumber();
        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 class
public class main{
                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);
        public static void main(String argv[]){
                Test te = new Test();

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

Please tell me what am I doing wrong.