简体   繁体   中英

Compile C++ native activity with NDK

I create Android native activity project based on " native-activity " project in NDK. In this project android_main function is implemented in main.c file and it compiles and run without any issues.

Now I wants to implement some C++ routines in this file and to do that, as a first step I change main.c file to main.cpp and change LOCAL_SRC_FILES entry in Android.mk to main.cpp .

After this change I got following error at the compilation:

make.exe: *** No rule to make target `jni/main.c', needed by `obj/local/arm64-v8a/objs/native-activity/main.o'.  Stop.

Also Android.mk file in this project contain following entries:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := native-activity
LOCAL_SRC_FILES := main.cpp
LOCAL_LDLIBS    := -llog -landroid -lEGL -lGLESv1_CM -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

What was the possible cause for this error?

Delete your obj directory from workspace and rebuild. Sometimes eclipse clean is not working and failed to delete obj files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM