javaeclipsejarjnaerator

Failed to use my JNAerator built jar though added it in the classpath


I've donwloaded the latest JNAerator jar (jnaerator-0.12-SNAPSHOT-20130609) here. Then, from my Ubuntu 13.04 64 bits, I translated a simple C source (just below) with the command :

java -jar jnaerator-0.12-SNAPSHOT-20130609.jar -gui -mode StandaloneJar operations.c

so that I get a jar operations.jar


operations.c :

int myAddtion(int a, int b){
    return a+b;
}

Then I add this jar to my Eclipse (Juno 4.1) test project build path : here the screenshot of my project organisation

My Eclipse project organisation

and here is the single source file of my project :

package com.gmail.loloof64.j2se.bon_compte.operations;

import operations.OperationsLibrary;

public class BonCompteTest {

    public static void main(String[] args) {
        System.out.println(OperationsLibrary.myAddtion(10, 30));
    }
}

But I get the following error output :

juil. 02, 2013 1:19:47 PM org.bridj.BridJ log
INFO: Library not found : operations
juil. 02, 2013 1:19:47 PM org.bridj.BridJ log
INFO: Library not found : operations
Exception in thread "main" java.lang.UnsatisfiedLinkError: operations.OperationsLibrary.myAddtion(II)I
    at operations.OperationsLibrary.myAddtion(Native Method)
    at com.gmail.loloof64.j2se.bon_compte.operations.BonCompteTest.main(BonCompteTest.java:8)
# BridJ: dlopen error when loading operations : operations: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type
# BridJ: dlopen error when loading operations : operations: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type

(The last sentence means : Can't open shared object file : No file or folder of this type).

I am using sun Java7 JDK (64 bits).

Does someone knows what I forgot ?

I am sure that there must be a problem like the fact that my C source file is missing, but I have tried to add it to the project, and to the jar, at several locations, but it did not solved my problem.

Regards


Solution

  • These logs (and your command line) seem to indicate that BridJ failed to find your native library (i.e. the .dll / .so / .dylib file). To fix that, you have a few options: