Setup Cocos2dx environment in Linux for Android (Part 2)

Hi again! If you’ve been able to accomplish the first one, and you’re aim to continue, thi is the second part. In this part, we’re going to run the TestCpp project of Cocos2dx in Android. It’s going to be shorter process than the previous one.

Before we start with the Android part, I want you to try to make a debug against the HelloCpp project in eclipse. In Debian I had a problem. My eclipse said “Error while launching command: gdb –version”. After a while I realized that I hadn’t installed it, and it’s necessary for debugging, so sudo apt-get install gdb.

Let’s start with Android. We have to define a couple of enviroment variables inside our eclipse. The first one, COCOS2DX must be defined in Eclipse->Preferences->General->Workspace->Linked Resources. Click in the New button and set the variable to the path of the uncompress folder of Cocos2dx, in my case /home/borja/Programas/cocos2d-x-2.1.4.

The second one, NDK_ROOT, must be defined in Eclipse->Preferences->C/C++->Build->Environment. Click in Add and set the variable value to the path of the uncompress folder of NDK, in my case /home/borja/Programas/android-ndk-r8e.

If you’re compiling the TestCpp project with the last version of Android like me, maybe the NDK shows this error android-ndk-r8e/build/core/ Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml. You can work around it by modify the file in the line 128, changing  $(call __ndk_warning by $(call __ndk_info.

Now, try to compile the TestCpp project, you should get an output console like this, but a little much longer :-).

Once the building process has finished, launch the app normally in an Android device, and everything should work well.


Thanks for read this. The new group of post that I’m going to write, will be about setup a continuous integration environment in general and for Android particulary.

See you soon!

One Reply to “Setup Cocos2dx environment in Linux for Android (Part 2)”

  1. I just got through with your first section on Cocos2d-x Linux setup, which was beyond excellent! Now I’m doing this on Ubuntu 3.10 and using Cocos2d-x-2.2.1–not exactly the same as your target system–but I had some serious discrepancies with this second part.

    1. libBox2D and libChipmunk had to be built (with Debug64!) before attempting to build TestCpp.

    2. I kept the WebSocket.cpp and .h files in libextension, and installed libwebsockets. When I built TestCpp, it failed, saying that WebSocket.h did not exist. I fixed this by adding ../../../../../extensions/network to the GCC C++ Compiler Include paths. (extensions was already there, but not its subfolder.)

    3. I then encountered this error: “./Classes/RenderTextureTest/RenderTextureTest.o: undefined reference to symbol ‘glEnable'”. I’m not sure whether this is the proper solution, but I added GL to the Libraries section under GCC C++ Linker, which fixed it.

    4. I then encountered “../../../../../extensions/proj.linux/Debug64/libextension.a(HttpClient.o): undefined reference to symbol ‘pthread_create@@GLIBC_2.2.5′”. This I fixed by adding pthread to the GCC C++ Linker libraries. ( I’m going to very, very ironic, in reference to the actual cause of this, and link you to this post ( which provides links to explanations :), though I didn’t use its solution. )

    5. Along similar lines, I had to add alut, openal, vorbis, vorbisfile (presumably because I chose to keep SimpleAudioEngineOpenAL.cpp in the first part rather than SimpleAudioEngineFMOD.cpp), and websockets to the linker libraries.

    6. And actually, then hell itself erupted out of the ground and demons dragged me screaming into the earth while carving pictures of the eclipse UI into my skin with serated knives. I now have 1905 undefined references, to everything–for instance, undefined references to “cocos2d::extension::UIMargin::UIMargin()”, a ton of functions in “cocos2d::extension::CCInputDelegate” and “cocos2d::extension::CCArmature”, and on and on and on and on. After several hours of utterly pointless and ineffectual attempts to solve this problem, my journey is over for today.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.