Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding cpp files to cocos2d-x project android project

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?

like image 266
Ferenc Dajka Avatar asked Dec 30 '13 14:12

Ferenc Dajka


People also ask

Can I use C++ in Cocos creator?

Cocos Creator supports JavaScript, built in. Edit your Scenes and source code all from within. However, If you are a C++ or Lua developer, Cocos Creator allows exporting of Scenes to sour code for further development.

What programming language does Cocos2d use?

Cocos2D suits companies that decide to build games and interactive apps that are 2D, developed with the C++ programming language, JavaScript, C# and Lua, and can be played on both Android and iOS mobile technologies, as well as across all the main operating systems (Windows, Mac, Linux).

How do I download Cocos2d-X?

To download Cocos2d-x, go to http://www.Cocos2d-x.org/download and download Version 2.2. 3 from the website. Once downloaded, you can unzip the Cocos2d-x-2.2.


1 Answers

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
like image 164
Dumitru Hristov Avatar answered Oct 16 '22 08:10

Dumitru Hristov