2

私のマシンでサンプル ネイティブ (cpp) コードをコンパイルしようとすると、これらのエラーが発生します。Cygwin の NDK を使用してネイティブ コードをコンパイルしようとしています。

以下のエラーが発生しています。LDFLAGS を追加しようとしましたが、まだ同じエラー LOCAL_LDLIBS := -llog が発生しています。

sh-4.1$ /cygdrive/c/Android/android-ndk-r6/ndk-build  
Compile++ thumb  : JNIExampleInterface <= JNIExampleInterface.cpp  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:5:44: error: android_runtime/AndroidRuntime.h: No such file or directory  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'void callback_handler(char*)':  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:36: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:51: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:59: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'void Java_com_nativeexample_JNIExampleInteace_callVoid(JNIEnv*, _jclass*)':  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:88: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function '_jobject* Java_com_nativeexample_JNIExamplnterface_getNewData(JNIEnv*, _jclass*, jint, _jstring*)':  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:103: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:110: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:117: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function '_jstring* Java_com_nativeexample_JNIExamplnterface_getStringInData(JNIEnv*, _jclass*, _jobject*)':  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:135: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:142: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'void initClassHelper(JNIEnv*, const char*,jobject**)':  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:163: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:170: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:177: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'jint JNI_OnLoad(JavaVM*, void*)':  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:193: error: 'LOGI' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:195: error: 'LOGE' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:221: error: 'android' has not been declared  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:222: error: 'NELEM' was not declared in this scope  
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:223: error: 'LOGE' was not declared in this scope  
make: *** [/cygdrive/d/EclipseWorkspace/NativeExample/obj/local/armeabi/objs/JNIExampleInterface/JNIExampleInterface.o  
Error 1  
sh-4.1$   

ネット
http://android.wooyd.org/JNIExample/の例に従っています

私が間違っている場合は、私を修正してください。私の質問が完璧でない、または理解できない場合は、コメントを残して、同じことを修正する機会をください。

よろしくお願いします、
SSuman185

4

2 に答える 2

2

以下の宣言を使用して、LOGE エラーのみを解決できます。

#define  LOG_TAG    "libJNIExInterface"  
#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)  
#define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

「android_log.....」の前にダブルアンダースコアが存在します。

Androidランタイムでネイティブ関数の登録を行う「NELEM」である他のエラーは必要ありませんが、Androidソースコードとともにこのアプリケーションをコンパイルするときに、Androidソースコード全体がある場合にのみ実行できます。それは不可能)。

そのため、Android の完全なソース コードがない場合、Android ランタイムの登録はできません。

于 2011-08-01T06:50:49.580 に答える
1

誰かがまだこの問題を抱えている場合:

ロギング マクロの名前が変更されましALOGEた。

于 2014-04-24T10:03:54.587 に答える