Adding cpp files to cocos2d-x project android project

核能气质少年 提交于 2019-12-06 03:31:27

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/20841693/adding-cpp-files-to-cocos2d-x-project-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!