Unable to compile project on Android whereas same project is working fine on iOS

Hi Guys,

I am trying to Port CocosDragon project, like I have seen many people are trying to do. http://code.zynga.com/2012/10/creating-a-game-with-cocosbuilder/

For starting, I create only MainMenuLayer and able to successfully compile over the iOS platform. However, if I try to use same code on Android platform. It fails to compile. For troubleshooting, I tried to compile TestCpp over Android and it is working fine.
I am unable to dig further that why my project source code is not compiling over Android.

I am getting following error:-

...Classes/MainMenuLayer.h:24: undefined reference to `vtable for MainMenuLayer'

I have attached the code files for the reference.

Any quick help will be highly appreciated.


MainMenuLayer.h.zip (0.7 KB)


MainMenuLayer.cpp.zip (0.8 KB)


MainMenuLayerLoader.h.zip (0.5 KB)

I have no idea.
Everything is ok.
Try to implement constructor in .cpp, but i am not sure.

Hi Minggo,

I already tried the method about implementing the constructor in cpp but still it is not working and then the error message is undefined reference to `MainMenuLayer::MainMenuLayer()'

Any other idea?

Thanks
Paras

I have placed the code at github for anyone who like to try the bug: https://github.com/CodeSnooker/DragonFly.git

Have you tried removing the constructor declaration in the .h file?

You have declared it in .h but not implemented it in the cpp.

I already marked {} in front of constructor in .h so it should be fine.

I tried all the possible combinations so far.

I guess the problem is somehow, NDK is not able to recognise these new files. Any suggestion about how to check that?

Did you add the .cpp file to the android.mk LOCAL_SRC_FILES list?

Did you modify the android.mk file in your android project to include your new created .cpp files?

No. Let me try it

Thanks Adam, Thanks Matthijis!

It works now. I didn’t know that I have to explicitly mention all the ccp files. I thought script automatically search in Classes folder.

Thanks a lot!
Paras

That got me the first few times (and the similar vtable error you get with constructor / destructor).