how to debug cocos2d-x(c++) in eclipse

how to debug cocos2d-x(c++) in eclipse
0.0 0


how to debug cocos2d-x(c++) in eclipse i have add pointbreak but can’t run


You need to be in Debug Perspective and click the Debug button instead of the Run button.


c++ can’t…java can


Actually it is possible.

You need to install NVidia debug manager for Android NDK ( But it also requires a lot of configuration and headache. Finally I managed to successful debug and hit breakpoints, but it was sooooo slow, and it is completely unuseful.

I use Eclipse as my primary IDE for cocos2d-x development. So I ended up developing in eclipse and debugging in visual studio for win32.


It is also possible just using the ADT. It takes quite a few changes but its possible to use breakpoints and step as well as inspect variables. Its not as clean and fast as using XCode but its not too bad.

Maybe we can come up with a minimal set of steps to make debugging in eclipse (ADT) work correctly and have the project template changed to reflect these changes.

I am running the following:
I am using Mac OS X
Android Developer Tools Build: v22.2.0-822323
Android NDK r9
cocos2d-x 3.0 alpha0

I will try to document a few things I believe were necessary in getting debugging working.
In a number of places I will reference /full/path/to/ please change those accordingly.

I added two import-add-path lines between the BUILD_SHARED_LIBRARY line and the import-module line:


    $(call import-add-path,/full/path/to/cocos2d-x/)
    $(call import-add-path,/full/path/to/cocos2d-x/cocos2dx/platform/third_party/android/prebuilt)

    $(call import-module,cocos2dx)

This is the contents of my file:

    APP_STL := gnustl_static
    APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix -O0 -gstabs+
    APP_ABI := armeabi
    APP_OPTIM := debug
    NDK_APP_OPTIM := debug
    NDK_DEBUG := 1
    APP_PLATFORM := android-14

The -O0 and -gstabs+ were required to make variable inspection work, i could not make it work without those at all.

In the project properties:
C/C++ Build -> Build Command:

    bash ${ProjDirPath}/ NDK_DEBUG=1 V=1

C/C++ Build -> Environment:
I have two added environment variables:



I created a debug configuration of type: Android Native Application
For that configuration, on the debugger tab, under Shared Libraries I added:


I hope I have not missed anything.

Lets try to figure out which parts are just my superstition and which are actually needed to debug. Its working quite well now and I am happy with it. I have issues from time to time that I believe are eclipse. For instance hovering to inspect variables just stopped working, but the Expressions tab in the debugger still shows them fine and I can view them using the GDB window as well.

  • Jerry