GameOverScene.h:47: undefined reference to `vtable for GameOverScene'


#1

Everything about cocos2dx is so fine before I try to add a new scene as tutorial in here : http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Chapter_7*-*Some_Icing_on_the_Cake

In the final step (adding the gameOverScene) of tutorial, a weird error occurs :
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/obj/local/armeabi/objs-debug/game_logic/HelloWorldScene.o: In function `GameOverScene’:
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/jni/…/…/Classes/GameOverScene.h:47: undefined reference to `vtable for GameOverScene’
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/obj/local/armeabi/objs-debug/game_logic/HelloWorldScene.o: In function `GameOverScene::node()‘:
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/jni/…/…/Classes/GameOverScene.h:50: undefined reference to `GameOverScene::init()’

I googled everywhere, and found it might caused by two reasons :

  1. typo : as the thread : http://www.cocos2d-x.org/boards/6/topics/2943?r=2949#message-2949
  2. makefile for jni : as the thread : http://gameit.ro/2011/08/adding-a-new-cpp-file-to-the-android-build-process-or-how-to-handle-the-undefined-reference-to-vtable-for-gameoverscene-error/

However, both of them do not work

I copy the code directly from website, so there is impossible a typo.
Moreover, I have added these source files to the jni/helloworld/Android.mk, as :
LOCAL_SRC_FILES := main.cpp …/…/…/Classes/AppDelegate.cpp …/…/…/Classes/HelloWorldScene.cpp …/…/…/Classes/GameOverScene.cpp

This error still jumps out when I compile it!

Can anyone help me?

I think that it must be a bug.


#2

Lixin Lou wrote:

Everything about cocos2dx is so fine before I try to add a new scene as tutorial in here : http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Chapter_7*-*Some_Icing_on_the_Cake
>
In the final step (adding the gameOverScene) of tutorial, a weird error occurs :
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/obj/local/armeabi/objs-debug/game_logic/HelloWorldScene.o: In function `GameOverScene’:
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/jni/…/…/Classes/GameOverScene.h:47: undefined reference to `vtable for GameOverScene’
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/obj/local/armeabi/objs-debug/game_logic/HelloWorldScene.o: In function `GameOverScene::node()‘:
/home/eddyxd/Android/Git/game/Cocos2dx/HelloWorld/android/jni/…/…/Classes/GameOverScene.h:50: undefined reference to `GameOverScene::init()’
>
>
I googled everywhere, and found it might caused by two reasons :

  1. typo : as the thread : http://www.cocos2d-x.org/boards/6/topics/2943?r=2949#message-2949
  2. makefile for jni : as the thread : http://gameit.ro/2011/08/adding-a-new-cpp-file-to-the-android-build-process-or-how-to-handle-the-undefined-reference-to-vtable-for-gameoverscene-error/
    >
    However, both of them do not work
    >
    I copy the code directly from website, so there is impossible a typo.
    Moreover, I have added these source files to the jni/helloworld/Android.mk, as :
    LOCAL_SRC_FILES := main.cpp > …/…/…/Classes/AppDelegate.cpp > …/…/…/Classes/HelloWorldScene.cpp > …/…/…/Classes/GameOverScene.cpp
    >
    >
    This error still jumps out when I compile it!
    >
    Can anyone help me?
    >
    I think that it must be a bug.

#3

u must add the reference of the new cpp file into the Android.mk of the Classes directory like:

LOCAL_SRC_FILES := AppDelegate.cpp HelloWorldScene.cpp GameOverScene.cpp


#4

Thanks Williams that fix my issue.


#5

Thanks Williams, I updated the tutorial, add “Notice on Android” section
[[Chapter 7 - Some Icing on the Cake#Notice on Android]]


#6

Williams Piazza wrote:

u must add the reference of the new cpp file into the Android.mk of the Classes directory like:
>
LOCAL_SRC_FILES := AppDelegate.cpp > HelloWorldScene.cpp > GameOverScene.cpp

yeah, you are right.