Share the experience of solving the problem of debug cocos2d-x code

Share the experience of solving the problem of debug cocos2d-x code
0.0 0


First of all, I’ll list some differences among most of the answers and tutorials on the net.
1) Operating System
Mac, Linux and Windows. There’re lots of tutorials on the net are based on Mac or Linux, unfortunately, my OS is Windows XP. Maybe someone said that’s not important. But my experience told me it really has differences of setting develop and debug environment, and these little differences will take your life…
2) NDK Codes
What I mean here is the cocos2d-x code is different with other ndk code. For example, I can run and debug the sample under the android-ndk folder normally, but when I run and debug cocos2d-x sample, the problems appeared. Error on environment settings, ndk-build, ndk-gdb…and so on.
3) Device
Generally, It’s the difference between AVD and cell-phone. And I also met the difference of different cell-phone, or It should be said the difference of different android system.

All right, now I’ll show my experience.
1) Never use ndk-build.cmd under android-ndk folder to compile the coco2d-x project, or it will show you an Error: “Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 20252” by libc.
Use to compile your project even it is said the will call ndk-build finally. Because will do many settings about cocos2d-x.
2) There are many tutorials teaching us to set environment in eclipse in order to build C++ code automatically. But in my case, set these environment for android-ndk project is OK, but for cocos2d-x project, I’ll failed sometime. And I still don’t know why it happened. Most of the time the console in eclipse shows the Error like: “recipe for target `main.o' failed make: *** [main.o]..”(here is not only main.o but also every file you’ve written in And when I use cygwin to compile it, it succeeded.)
Here are two tutorials that I think they are better than others on the net.
For android-ndk:
For cocos2d-x:
What? The tutorials for cocos2d-x is in Chinese? Well, learn it! Just like Chinese have to learn English before reading tutorials for ndk.
3) Maybe cocos2d-x Offical has find the problem of using ndk-gdb to debug cocos2d-x project will call Error: The device does not support the application's targetted CPU ABIs! So in cocos2d-x-2.0.4 they add a file: under sample’s folder. Do not hesitate! Just use it! With this file, you’ll kick all the previous fucking problems out! But pay a little attention, before use this artifact, please set SDK_ROOT in file .bash_profile under cygwin/bin like you set NDK_ROOT as well. And just use SDK_ROOT and NDK_ROOT as the path name. Or you’ll regret!
And, this operation is also run in cygwin, I try to set it in eclipse like the ndk tutorials but failed. the console shows:
@ -target-select remote localhost:5039
30^error,msg=“Remote communication error. Target disconnected.: No such file or directory.”@

OK, now that I can compile the cocos2d-x project, run it and even debug it! Maybe many detials I’ve not written here. Because I’ve tried to solve these problems for almost two weeks, there are too many problems. I can’t remember all the detail. However, they are similar and you can find most error information in the ndk-gdb script.

And finally, I really thank Kevin H. He(or she?) had helped me a lot during the time that I’m solving the problems. I hope what I’ve written would help others who would also met these problems.