JNI C++ UnsatisfiedLinkError When Calling Method

AJavaProgrammer

I have been trying to create a simple JNI Test with C++. For Java I am using Eclipse, and for C++ I am using Visual Studio 2013. I followed the directions on other pages on StackOverFlow but nothing really seems to work. The error occurs when I try calling the native method in java listed in C++.

Thanks for your time.

Header.h

#include <jni.h>;
using namespace std;
#ifndef Header
#define Header
JNIEXPORT void JNICALL Java_base_Main_print(JNIEnv *env, jobject obj);
#endif

Edited Header.h (solution which worked)

#include <jni.h>;
using namespace std;

#ifndef Header
#define Header

extern "C" {
JNIEXPORT void JNICALL Java_base_Main_print(JNIEnv *env, jobject obj);
}
#endif

JNIHelloWorld.cpp

#include "Header.h";

JNIEXPORT void JNICALL Java_base_Main_print(JNIEnv *env, jobject obj) {
    printf("This is a JNI tester\n");
    //return;
}

JavaCode

package base;
public class Main {
    static {System.loadLibrary("JNIHelloWorld");}
    public static void main(String args[]){
        Main m = new Main();
        m.print();
    }
    public native void print();
}

Error

Exception in thread "main" java.lang.UnsatisfiedLinkError: base.Main.print()V
    at base.Main.print(Native Method)
    at base.Main.main(Main.java:9)
Raindog

try #extern "c" { } around the JNI code.

Verify by looking at the exports of your DLL to see that the C++ name mangling did not get involved.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

C++ JNI UnsatisfiedLinkError

From Java

How do I avoid UnsatisfiedLinkError when calling C++ from java from C++ application?

From Java

JNI: Library is Found on Path, but Method is not (java.lang.UnsatisfiedLinkError)

From Dev

JNI- java.lang.UnsatisfiedLinkError: Native method not found

From Dev

java.lang.UnsatisfiedLinkError when using JNI on ubuntu

From Dev

C++ Inheritance : Calling virtual method when it has been overridden

From Dev

JNI UnsatisfiedLinkError without wrong method names and with library path specified

From Dev

Calling a static void Java method from JNI

From Dev

c++ error when calling method

From Dev

Java JNI NullPointerException after calling method from C with valid pointers

From Dev

appending values each time when calling JNI method

From Dev

Calling dll implemented JNI from C++

From Dev

JNI Calling Java Method With Array Parameter

From Dev

Why android Jni crashed when calling c method which in shared library?

From Dev

Calling C system calls from JNI

From Dev

Calling java function from c++ using jni: Failed to find static method id

From Dev

What's "Method Signature" parameter when calling a Java method using JNI?

From Dev

Error when calling method

From Dev

UnsatisfiedLinkError when calling new World()

From Dev

Calling a method when a listview item is focused C#

From Dev

JNI java.lang.UnsatisfiedLinkError,cannot link method

From Dev

JNI: Calling a java method from C periodically is not working

From Dev

c# parameters change when calling method

From Dev

How to resolve UnsatisfiedLinkError when using JNI with packages?

From Dev

Calling RenderScript from C / JNI

From Dev

Error when calling static method c++

From Dev

How to resolve a Bad global or local ref passed to JNI error when calling a java method from native code

From Dev

Calling JNI C function in another source file

From Dev

C# Is it possible to convert EventArgs to FormClosingEventArgs when calling method in a method?

Related Related

  1. 1

    C++ JNI UnsatisfiedLinkError

  2. 2

    How do I avoid UnsatisfiedLinkError when calling C++ from java from C++ application?

  3. 3

    JNI: Library is Found on Path, but Method is not (java.lang.UnsatisfiedLinkError)

  4. 4

    JNI- java.lang.UnsatisfiedLinkError: Native method not found

  5. 5

    java.lang.UnsatisfiedLinkError when using JNI on ubuntu

  6. 6

    C++ Inheritance : Calling virtual method when it has been overridden

  7. 7

    JNI UnsatisfiedLinkError without wrong method names and with library path specified

  8. 8

    Calling a static void Java method from JNI

  9. 9

    c++ error when calling method

  10. 10

    Java JNI NullPointerException after calling method from C with valid pointers

  11. 11

    appending values each time when calling JNI method

  12. 12

    Calling dll implemented JNI from C++

  13. 13

    JNI Calling Java Method With Array Parameter

  14. 14

    Why android Jni crashed when calling c method which in shared library?

  15. 15

    Calling C system calls from JNI

  16. 16

    Calling java function from c++ using jni: Failed to find static method id

  17. 17

    What's "Method Signature" parameter when calling a Java method using JNI?

  18. 18

    Error when calling method

  19. 19

    UnsatisfiedLinkError when calling new World()

  20. 20

    Calling a method when a listview item is focused C#

  21. 21

    JNI java.lang.UnsatisfiedLinkError,cannot link method

  22. 22

    JNI: Calling a java method from C periodically is not working

  23. 23

    c# parameters change when calling method

  24. 24

    How to resolve UnsatisfiedLinkError when using JNI with packages?

  25. 25

    Calling RenderScript from C / JNI

  26. 26

    Error when calling static method c++

  27. 27

    How to resolve a Bad global or local ref passed to JNI error when calling a java method from native code

  28. 28

    Calling JNI C function in another source file

  29. 29

    C# Is it possible to convert EventArgs to FormClosingEventArgs when calling method in a method?

HotTag

Archive