Paul Kinzelman
Paul Kinzelman

Reputation: 565

Android.mk will compile .c source but not .cpp

I have an Android.mk file that compiles my NDK C code just fine:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := galib
LOCAL_SRC_FILES := galib.c tables-lr35-contam.c tables-lr35-perf.c
LOCAL_CFLAGS    := -DTARGET_ANDROID=1
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 
include $(BUILD_SHARED_LIBRARY)

I'd like to call the first source galib.cpp instead of .c because that's the name I need it to be when compiling it in the WPF environment. It really is just C code but to make a DLL I have to name it .cpp for it to handle the __declspec(dllexport) stuff properly.

However, when I rename it galib.cpp and change the .mk file to say the same and try to build it for Android, I get the error:

$ ndk-build
make: *** No rule to make target `/cygdrive/c/apk/adev/android/etold/jni/galib.c',
    ...needed by `/cygdrive/c/apk/adev/android/etold/obj/local/armeabi/objs/galib/galib.o'.  Stop.

as though it still wants a .c file for some reason. I also tried "ndk-build -B" in case there's something left over from the .c build, but that results in the same error. Any idea why? Thanks!

Upvotes: 0

Views: 2135

Answers (1)

genk
genk

Reputation: 321

I know that you asked that long time ago. But anyway - for other people like me:

I tackled into this problem too just now. For some reason clean build doesn't do the job even when you change the sources list at LOCAL_SRC_FILES. I had to navigate to \obj\local\armeabi\objs\ within the project and clean .o files manually.

After that it compiled fine.

Upvotes: 4

Related Questions