COCOS2DX porting Eclipse, developed with the NDK, implementing the Discard Vs,eclipse write C + + code

Source: Internet
Author: User

1. Disclaimer: Readers of this blog post are applicable to the people who compiled success in Eclipse to run the COCOS2DX project

2. The game engine I use is the cocos2dx2.2.2 version

The 3.NDK version is android-ndk-r8d

4. I ported my COCOS2DX project to eclipse, opened the class I wrote in VS, and found that some of the classes have the following, which is not really a problem, just the project I'm importing

Can't find something, you turn this class off, run the program to find the error, but the project shows that there is no error, then you turn off the project, recompile is available

5. Write here, someone may ask, since the above solution has been provided, it is not good, but you do not think that will be very tired, a little modification of things to shut down the project, re-come,

The key is to report such errors, it will make you suspect that you fill in the authenticity of the code, I would like to introduce a method, is to discard the COCOS2DX project comes with the cocos2dx,classes and other folders, directly compiled with the NDK, so you can debug

6. Copy your Classes folder to the Jni folder and modify the Android.mk file



For

The reason for this is very simple, we look at the directory structure will be found in the ANDROID.MK directory structure is based on the JNI root directory, the original classes is in the first two directories of the JNI directory, now your directory structure changed, the configuration information of course change

7. Of course, the change here is still very far from our goal, right click on your project, select Properties, select C/S build modified as follows

The purpose of this step is to debug

8. Expand C + + Build selection tool Chain Editor with the following configuration information

Please note that the key point in this drop-down box is the no toolchain option, congratulations you are lucky, because there may be the following situation



Did you find out? No toolchain option is not, this is a tragedy of a situation, is also a blogger encountered, but also let me make up my mind to write this blog, when encountered, your entire project is wasted, no matter how you modify (may be I do not understand) can not compile successful projects, the project error is as follows:

9. This error, according to my understanding is that the key command can not be found, there is a compilation problem, this problem Bo master is resolved:

A. First of all, you may have never paid attention to the. cproject file in the Proj.android folder under your project. This file is actually a configuration file for the project, and when we make a change to the project configuration, the information is stored in this file, no The toolchain option does not have the problem that appears here, the configuration file does not have, then I attach a correct configuration file:

<?xml version= "1.0" encoding= "UTF-8" standalone= "no"?>
<?fileversion 4.0.0?><cproject storage_type_id= "Org.eclipse.cdt.core.XmlProjectDescriptionStorage" >
<storagemodule moduleid= "Org.eclipse.cdt.core.settings" >
<cconfiguration id= "com.android.toolchain.gcc.2083618597" >
<storagemodule buildsystemid= "Org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id= " com.android.toolchain.gcc.2083618597 "moduleid=" org.eclipse.cdt.core.settings "name=" Default ">
<externalSettings/>
<extensions>
<extension id= "Org.eclipse.cdt.core.ELF" point= "Org.eclipse.cdt.core.BinaryParser"/>
<extension id= "Org.eclipse.cdt.core.VCErrorParser" point= "Org.eclipse.cdt.core.ErrorParser"/>
<extension id= "Org.eclipse.cdt.core.GmakeErrorParser" point= "Org.eclipse.cdt.core.ErrorParser"/>
<extension id= "Org.eclipse.cdt.core.CWDLocator" point= "Org.eclipse.cdt.core.ErrorParser"/>
<extension id= "Org.eclipse.cdt.core.MakeErrorParser" point= "Org.eclipse.cdt.core.ErrorParser"/>
<extension id= "Org.eclipse.cdt.core.GCCErrorParser" point= "Org.eclipse.cdt.core.ErrorParser"/>
<extension id= "Org.eclipse.cdt.core.GASErrorParser" point= "Org.eclipse.cdt.core.ErrorParser"/>
<extension id= "Org.eclipse.cdt.core.GLDErrorParser" point= "Org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storagemodule moduleid= "Cdtbuildsystem" version= "4.0.0" >
<configuration artifactname= "${projname}" buildproperties= "" description= "" id= " com.android.toolchain.gcc.2083618597 "Name=" Default "parent=" Org.eclipse.cdt.build.core.emptycfg ">
<folderinfo id= "com.android.toolchain.gcc.2083618597.1746542775" name= "/" Resourcepath= "" >
<toolchain id= "com.android.toolchain.gcc.207752166" name= "COM.ANDROID.TOOLCHAIN.GCC" superclass= " COM.ANDROID.TOOLCHAIN.GCC ">
<targetplatform binaryparser= "Org.eclipse.cdt.core.ELF" id= "com.android.targetplatform.1333423178" isabstract= "False" superclass= "Com.android.targetPlatform"/>
<builder arguments= "ndk_debug=1" buildpath= "${projdirpath}" command= "Ndk-build" id= " com.android.builder.1306964325 "keepenvironmentinbuildfile=" false "managedbuildon=" false "Name=" Android Builder " superclass= "Com.android.builder" >
<outputEntries>
<entry flags= "value_workspace_path| Resolved "kind=" OutputPath "name=" obj "/>
<entry flags= "value_workspace_path| Resolved "kind=" OutputPath "name=" Libs "/>
</outputEntries>
</builder>
<tool id= "com.android.gcc.compiler.647000292" name= "android gcc compiler" superclass= "Com.android.gcc.compiler" >
<inputtype id= "com.android.gcc.inputtype.1035220464" superclass= "Com.android.gcc.inputType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags= "value_workspace_path| Resolved "kind=" SourcePath "name=" JNI "/>
</sourceEntries>
</configuration>
</storageModule>
<storagemodule moduleid= "Org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storagemodule moduleid= "Cdtbuildsystem" version= "4.0.0" >
<project id= "legend214.null.671703336" name= "legend214"/>
</storageModule>
<storagemodule moduleid= "Org.eclipse.cdt.core.pathentry"/>
<storagemodule moduleid= "Refreshscope" versionnumber= "1" >
<resource resourcetype= "PROJECT" workspacepath= "/cocosbudier"/>
</storageModule>
<storagemodule moduleid= "Scannerconfiguration" >
<autodiscovery enabled= "true" problemreportingenabled= "true" selectedprofileid= ""/>
<scannerconfigbuildinfo instanceid= "com.android.toolchain.gcc.2083618597; com.android.toolchain.gcc.2083618597.1746542775;com.android.gcc.compiler.647000292; com.android.gcc.inputtype.1035220464 ">
<autodiscovery enabled= "true" problemreportingenabled= "true" selectedprofileid= " Com.android.AndroidPerProjectProfile "/>
</scannerConfigBuildInfo>
<scannerconfigbuildinfo instanceid= "0.756827735;0.756827735.; com.android.gcc.compiler.1510055343;com.android.gcc.inputtype.974093260 ">
<autodiscovery enabled= "true" problemreportingenabled= "true" selectedprofileid= " Com.android.AndroidPerProjectProfile "/>
</scannerConfigBuildInfo>
</storageModule>
<storagemodule moduleid= "Org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
</cproject>

Replace, update the project, see again, found no toolchain option appears, congratulations on your success is very close, compile the project, or an error occurred


It means the Ndk_module_path is not set.

  1. Here we do not set Ndk_module_path, because set it will let us not debug C + + code, solve the above problem is: the compilation process needed to copy the library to the system default Ndk_module_path, follow me to do
  2. Copy these 4 directories under the cocos2d-2.1rc0-x-2.1.3 directory cocos2dx,CocosDenshion,extensions,external to your ndk's sources directory, take my computer for example, is/android/android-ndk-r8e/sources
  3. Copy all of the cocos2d-2.1rc0-x-2.1.3/cocos2dx/platform/third_party/android/prebuilt directories into the sources directory of the NDK
  4. So we copy the directory to the NDK's sources directory. cocos2dx,CocosDenshion,extensions,external, libcurl,libjpeg,libpng,libtiff,libwebp
  5. Back to eclipse, project->build all again, should compile successfully

Here, I quoted the http://blog.csdn.net/tt5267621/article/details/8940768 method.

Now we should compile again and it will be successful.

PS: If you have any good suggestions please feel free to communicate with me, I hope this blog post can benefit everyone, and if you encounter any problems in this process, please leave a message, I will be the fastest speed to reply to everyone

COCOS2DX porting Eclipse, developed with the NDK, implementing the Discard Vs,eclipse write C + + code

Related Article

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.