2013-07-30 3 views
0

동안 난 다음 튜토리얼 http://taylorpeer.com/hello-world-cpp-android-ndk/NDK 빌드 오류가 컴파일 소스 코드

을 다음입니다. 내가 src 폴더

에있는 내 파일

자바 파일의 목록입니다 다음 다음과 같은 오류가

Compile++ thumb : hello-jni <= hello-jni.cpp 
jni/hello-jni.cpp:4:5: error: stray '\342' in program 
jni/hello-jni.cpp:4:5: error: stray '\200' in program 
jni/hello-jni.cpp:4:5: error: stray '\234' in program 
jni/hello-jni.cpp:4:5: error: stray '\342' in program 
jni/hello-jni.cpp:4:5: error: stray '\200' in program 
jni/hello-jni.cpp:4:5: error: stray '\235' in program 
jni/hello-jni.cpp:9:17: error: stray '\342' in program 
jni/hello-jni.cpp:9:17: error: stray '\200' in program 
jni/hello-jni.cpp:9:17: error: stray '\234' in program 
jni/hello-jni.cpp:9:17: error: stray '\342' in program 
jni/hello-jni.cpp:9:17: error: stray '\200' in program 
jni/hello-jni.cpp:9:17: error: stray '\235' in program 
jni/hello-jni.cpp:4:15: error: 'C' does not name a type 
make: *** [obj/local/armeabi/objs/hello-jni/hello-jni.o] Error 1 

얻을.

package com.example; 
import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView; 

    public class Hellojnicpp extends Activity { 
      /** Called when the activity is first created. */ 
      @Override 
      public void onCreate(Bundle savedInstanceState) { 
       super.onCreate(savedInstanceState); 
       /** Create a TextView and set it to display 
       * text loaded from a native method. 
       */ 
       TextView tv = new TextView(this); 
       tv.setText(stringFromJNI()); 
       setContentView(tv); 
      } 
      /** A native method that is implemented by the 
      * ‘hello-jni’ native library, which is packaged 
      * with this application. 
      */ 
      public native String stringFromJNI(); 
      /** Load the native library where the native method 
      * is stored. 
      */ 
      static { 
       System.loadLibrary("hello-jni"); 
      } 
    } 

Android.mk 파일

LOCAL_PATH := $(call my-dir) 


include $(CLEAR_VARS) 
LOCAL_LDLIBS := -llog 

LOCAL_MODULE := hello-jni 
LOCAL_SRC_FILES := hello-jni.cpp 

include $(BUILD_SHARED_LIBRARY) 

.cpp 파일

#include <string.h> 
#include <jni.h> 

    extern “C” { 
      JNIEXPORT jstring JNICALL 
      Java_com_example_Hellojnicpp_stringFromJNI 
      (JNIEnv *env, jobject obj) 
      { 
       return env->NewStringUTF(“Hello from C++ over JNI!”); 
      } 
    } 

이미 지난 72 시간 을에서 인터넷을 검색하는 오류를 수정에서 저를 도와주세요 감사합니다. N

지금

extern "C" 

즉, 어떠한 "둥근"인용 없어야에 "C""C" 변경 후

Compile++ thumb : hello-jni <= hello-jni.cpp 
jni/hello-jni.cpp:9:17: error: stray '\342' in program 
jni/hello-jni.cpp:9:17: error: stray '\200' in program 
jni/hello-jni.cpp:9:17: error: stray '\234' in program 
jni/hello-jni.cpp:9:17: error: stray '\342' in program 
jni/hello-jni.cpp:9:17: error: stray '\200' in program 
jni/hello-jni.cpp:9:17: error: stray '\235' in program 
jni/hello-jni.cpp: In function '_jstring* Java_com_example_Hellojnicpp_stringFromJNI(JNIEnv*, jobject)': 
jni/hello-jni.cpp:9:45: error: 'Hello' was not declared in this scope 
make: *** [obj/local/armeabi/objs/hello-jni/hello-jni.o] Error 1 
+0

견적도 잘못된 것입니다. 나는 대답으로 그것을 고쳤다. 그것을 시도하십시오 – yushulx

답변

2

은 ""확인 : 문자열

#include <string.h> 
#include <jni.h> 

    extern "C" { 
      JNIEXPORT jstring JNICALL 
      Java_com_example_Hellojnicpp_stringFromJNI 
      (JNIEnv *env, jobject obj) 
      { 
       return env->NewStringUTF("Hello from C++ over JNI!"); 
      } 
    } 
1
extern “C” 

을 다음과 같은 오류가 진행한다. 텍스트 편집기가 직선 따옴표를 "미화"하지 않도록하십시오.

+0

"C"로 extern "C"를 변경하고 이제 다른 오류가 발생 –

+0

내 최신 오류 및 도움말을 확인하시기 바랍니다 –

+0

음, 보자, 당신은 중괄호와 라인에 오류가있어. 그 줄에 곱슬 따옴표를 사용하지 말라고했는데, 곱슬 곱슬 따옴표가 들어있는 다른 줄에서도 여전히 비슷한 오류가 발생합니다. Android NDK를 효과적으로 사용하기에 충분한 프로그래밍 경험이 아직 없다고 정중하게 제안 할 의향이 있습니까? – wolfgang