Windows (free cygwin) Eclipse debugging C + + (COCOS2DX Android)

Source: Internet
Author: User

Original link: http://www.cnblogs.com/zouzf/p/4202537.html

First say Windows under, Mac under the last

Environment: win8.1, Java 1.5, Eclipse 4.3.1, ADT bundle 22.6.2.v20140321, NDK r8e, Cocos2dx 2.2.3

Prerequisite: Download Good cocos2dx, NDK (r8e above version can not install Cygwin), ADT bundle (with Eclipse, SDK and other plug-ins), Configuration good java_home, CLASSPATH, Ndk_root, android_ Environment variables such as SDK, configuring COCOS2DX's Android development environment, which can generate. so files, build jar packages, and successfully run Hellocpp projects by Ndk-build compiling COCOS2DX. Note: All the directories involved do not have Chinese or white space!

1. Delete the. metadata file from Eclipse's workspace directory, yes, Eclipse I set the not auto build~~ and then turn on Eclipse COCOS2DX project (Q:\cocos2d-x-2.2.3\ cocos2dx\platform\android) and Hellocpp Engineering (Q:\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.android) in:file-> Import->android->existing Android Code into workspace->next< the directory where the COCOS2DX project is located in root directory, press ENTER, COCOS2DX project will appear, and will be automatically selected, point to finish, done. In the same way, the Hellocpp project is also guided.

2, Testcpp project Error said do not know bash:error:program "bash" not found in PATH

Resolution: (1): Configure the NDK path for Eclipse

   (2): Set up the Testcpp project's C + + Builder:ndk-build.cmd ndk_debug=1. Note: Do not leave spaces around ndk_debug=1 equals sign

3, build a Testcpp project, will error:

1 d:/new_soft/android-ndk-r8e/build/core/add-application.mk: android NDK:WARNING:APP_ PLATFORM android-9is8in./androidmanifest.xml   

The project in the Androidmanifest.xml file <uses-sdk android:minsdkversion= "8"/> 8 changed to 9. Checked the article, said it was a bug:AndroidManifest.xml in the NDK. The minsdkversion setting cannot be less than the version of the SDK that the project uses for compiling, and the SDK version of the Hellocpp project for compiling is 2.2.3 .... That is, Sdkversion is 9 .....

4, refresh, then build, also reported error:

 1  jni/android.mk:19 : *** Android ndk:aborting.  . Stop.  2   Android ndk:jni/android.mk:cannot find module with tag  '  

said that the android.mk file in the 19 lines can not find cocos2dx, probably means to find this COCOS2DX module, similar to the # include header file to add the corresponding search path meaning, Then make up the previous level of the module: Open the Android.mk file and add a line before the last line of $ (call IMPORT-MODULE,COCOS2DX): $ (Call import-add-path,q:/ cocos2d-x-2.2.3). That is, add cocos2dx This folder is located in the directory to the Mk file to search.

Notice the backslash inside: We are Q:\cocos2d-x-2.2.3 when we copy the path directly from Windows, we have to change \ to/. If your COCOS2DX project is located in a deep directory, there are many layers, you have to change the path of all the \ .

5, refresh, then build, also reported error:

1Android NDK:q:/cocos2d-x-2.2. 3/cocos2dx/android.mk:cannot find module with tag 'libjpeg'   inImport Path  2q:/cocos2d-x-2.2.3/COCOS2DX/ANDROID.MK:175: ***Android ndk:aborting.  . Stop.3Android Ndk:are you sure your ndk_module_path variable isProperly defined?4 Android ndk:the following directories were searched:5Android NDK:

Well, the same mistake, said the COCOS2DX project of the Android.mk file of the 175 line on the LIBJEPG, note that the COCOS2DX Project Mk file is not in its engineering directory, but on its upper two layer, in q:/cocos2dx-2.2.3/ COCOS2DX below, open it, insert a sentence before the $ (call import-module,libjpeg) of 175 lines: $ (call import-add-path,q:/cocos2d-x-2.2.3/cocos2dx/ platform/third_party/android/prebuilt). Notice that the slash turns into a backslash! Because LIBJEPG is a third-party library, it is placed in the Cocos2dx\platform\third_party\android\prebuilt directory.

Note: The 4th, 5 steps to add NDK module are used absolute path, on different computers to reconfigure. You can also change to a relative path, but I'm not too familiar with the Mk file some things, and then change ~ ~

6, again build, Ah, seems to succeed, the successful generation of libhellocpp.so file ~ ~ See Libs folder generated a gdbserver file and Gdb.setup file No, is because the above settings ndk_debug=1 so generated, Gdbserver will be deployed to the phone. When the C + + breakpoint is triggered, the equivalent of the phone side of the gdbserver is the service side, will send some information to eclipse this side, eclipse this side of the Gbdserver is the client, eclipse this side of the Gdbserver received the information on the relevant operation, well, I guess ~~

Here's how to debug a CPP file.

1, right button COCOS2DX project, select Android Tools, Add Native support,so file name don't change, dot finish

2, refresh, build COCOS2DX project, Error:

D:/NEW_SOFT/ANDROID-NDK-R8E/BUILD/CORE/ADD-APPLICATION.MK:android NDK:WARNING:APP_PLATFORM android- 9  is 8  in./androidmanifest.xml  

Androidmanifest.xml <uses-sdk android:minsdkversion= "8"/> in the project to 9.

3, refresh, build COCOS2DX project, no error, then build Hellocpp project, also did not error

4. Add C + + files that need to be debugged:

(1): Right-click Hellocpp Project, New->folder

    

(2): Select Hellocpp, below Advanced, select the last option: Link to alternate location (Linked Folder), enter the directory where you want to import the CPP (I filled in the q:\ cocos2d-x-2.2.3\samples\cpp\hellocpp\classes), click Finish to:

      

Note: The folder name cannot be the same as the file already in the project .

5, open the CCNode.cpp file just added, found a lot of errors, including a variety of # include. h files can not be found, a variety of unrecognized symbols or various unknown symbol~~, I guess this problem is because only a few CPP files are imported, These CPP files rely on other CPP files are not added reasons, if all the CPP files are added to the estimate is possible, I have not tried ~ ~ (because the LIBCOCOS2DX project under the directory COCOS2DX, can not directly add cocos2dx this directory, To put inside the cocosdenshion, extensions and other directories add in ~ ~)

Workaround: Right-click the COCOS2DX project, properties, C + + general->code analysis, select Use Project Settings, and then remove the following tick, as follows:

  

6, refresh, build two projects, there should be no problem

7, in just add in any CPP file in the breakpoint, right-click the Hellocpp project, debug as->android native application (please use the real machine debugging, with the simulator's words do not know what the problem is not), actually error:

  

8, the original is the Assert folder in the resources did not, may also be relative to the path and problems caused by it, did not put resources in the resource copy over it, put Q:\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\ All the things in the resources are handcuffed to Q:\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.android\assets, then run, debug as->android native Application, Success!

Note: When debugging C + +, Gdbserver will be delayed (about a few seconds, with the performance of your computer and the debug phone), so your breakpoint should not be added to the program startup code, which is added in a menu click event, click the Close menu trigger.

Thread, single step, variable observation ~~perfect~~

PS: Because I used the eclipse added a Chinese package ... But also want to in the article related to eclipse set up some things as far as possible in English version of ... There are some places in the words and the difference, forgive me ~ ~

Feel the focus of this thing is to understand the Android.mk file, the inside of the configuration to understand, in the process of reading what is wrong, the corresponding modification just. Anyway I still do not know, so the article is full of a lot of I guess the words ~ ~ First Use, and then study it

Mac is almost this step, if you have any problem, put the details, I try to share what I know ~ ~

The Mac is clearly configured Ndk_root,eclipse run time has been said to find: directly in the corresponding project of the first line of the Mk file set ndk_root= "~~~~~~~~~~" (~ ~ ~ means that your NDK is located in the directory, such as: d:/new_soft/ android-ndk-r8e)

Original link: http://www.cnblogs.com/zouzf/p/4202537.html

Windows (free cygwin) Eclipse debugging C + + (COCOS2DX Android)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.