Adding cpp files to cocos2d-x project android project
Asked Answered
C

1

5

I've followed this tutorial http://www.raywenderlich.com/33750/cocos2d-x-tutorial-for-ios-and-android-getting-started, and managed to create an android hello world project in cococs2d-x. Now when I add anything to my classes directory and try to use them, I get errors like

make: *** [obj/local/armeabi/libgame.so] Error 1
undefined reference to 'ConstAndStats::getDevice()' 

How should I fix these problems, and add the already working codes (in Xcode) for my eclipse project?

Colonel answered 30/12, 2013 at 14:39 Comment(0)
N
8

This kind of error may appear if you add a class to the classes directory but forget to add it to the Android.mk file from the jni folder. Add something like this:

LOCAL_SRC_FILES := hellocpp/main.cpp \
          ../../Classes/YourClass.cpp \
          ../../Classes/YourLastClass.cpp
Northwesterly answered 30/12, 2013 at 14:48 Comment(2)
yeah I thought that the problem is something like this, now that I added the correct cpp file I got this error: make: *** No rule to make target jni/../../Classes/ConstAndStats.cpp', needed by obj/local/armeabi/objs-debug/game_shared/__/__/Classes/ConstAndStats.o'. Stop. asad C/C++ ProblemColonel
ok my class name is ConstsAndStats.cpp not ConstAndStats.cpp (plural), so it was a mispelling. thanks!Colonel

© 2022 - 2024 — McMap. All rights reserved.