C ++ DLL中的JNI UnsatisfiedLinkError

时间:2018-06-11 08:33:30

标签: java java-native-interface

我使用JNI来调用一个简单的hello world函数。

public class HelloJNI { static { System.loadLibrary("hello"); } private native void sayHello(); public static void main(String[] args) { new HelloJNI().sayHello(); } }

hello.dll

我在同一目录中有PATH个文件。

我甚至已将目录添加到Exception in thread "main" java.lang.UnsatisfiedLinkError: HelloJNI.sayHello()V at HelloJNI.sayHello(Native Method) at HelloJNI.main(HelloJNI.java:9)变量。

仍然无法正常工作。

提前致谢。

错误:

#include "jni.h" #include <iostream> #include "HelloJNI.h" using namespace std; // Implementation of native method sayHello() of HelloJNI class JNIEXPORT void JNICALL Java_HelloJNI_sayHello(JNIEnv *env, jobject thisObj){ cout << "Hello World from C++!" << endl; return; }

C ++文件:

/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class HelloJNI */

#ifndef _Included_HelloJNI
#define _Included_HelloJNI
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class:     HelloJNI
* Method:    sayHello
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloJNI_sayHello
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

标题文件:

    import tweepy
    from tweepy import OAuthHandler 
    access_token="---------" 
    access_token_secret="----------" 
    consumer_key="---------" 
    consumer_secret="-------"    
    auth = OAuthHandler(consumer_key, consumer_secret) 
    auth.set_access_token(access_token, access_token_secret)    
    api = tweepy.API(auth)    
    public_tweets = api.home_timeline()    
    print("public_tweets.text")

0 个答案:

没有答案