How to get prebuilt Libraries to work with NDK-10e? - vtable linker errors

I’m trying to use the newest NDK-10, but I’m getting errors like this one when building.

MySprite is a Sprite subclass. It compiles fine on iOS. Everything compiles fine with NDK-9, but I’m getting warnings there, that certain things will crash on Android 5, etc.

[armeabi] Compile++ thumb: cocos2dcpp_shared <= MySprite.cpp
[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] Gdbserver      : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[armeabi] SharedLibrary  : libcocos2dcpp.so
./obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/MySprite.o:MySprite.cpp:vtable for MySprite: error: undefined reference to 'cocos2d::Sprite::setDisplayFrameWithAnimationName(std::string const&, int)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make: Leaving directory `/Users/Max/Documents/CocosProjects/MyProject/proj.android'
Error running command, return code: 2.

Demo Project: https://dl.dropboxusercontent.com/u/40859730/LinkerProblem.zip

(You need to change the build-cfg.json to point to your prebuilt libs)

I would say, it’s not about prebuild libs.

  1. It works with NDK-10 (e,d) versions tested myself

  2. It seems issue with your code, maybe missing some cocos2d file include(try include in Mysprite.cpp cocos2d.h file) or incorrect setup for Android.mk. For sure you can try to compile new fresh just created project to see that it works.

Okay thanks for your help.

I’m already including cocos2d.h in MySprite.h (and therefore also Mysprite.cpp).

Android.mk looks like this, any more ideas?

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos/prebuilt-mk)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := main.cpp \
                   ../../Classes/AppDelegate.cpp \
                   ../../Classes/HelloWorldScene.cpp \
                   ../../Classes/MySprite.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

$(call import-module,.)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

I can compile a fresh project, but as soon as I add a sprite subclass, it stops working with the linker error.
What might I be doing wrong?

Better share your project full code, it looks ike some easy mistake :0

Here’s a sample project:

https://dl.dropboxusercontent.com/u/40859730/LinkerProblem.zip

I fixed it thanks to the help of energyy,

I had to do:
cocos gen-libs android -m debug

instead of:
cocos gen-libs

I thought this command would just build everything, but apparently it doesn’t.