Ubuntu14.04+eclipse under the COCOS2D-X3.0 Official edition environment Construction

Source: Internet
Author: User
Tags joins

Environment:

ubuntu14.04

Adt-bundle-linux-x86_64

Android-ndk-r9d-linux-x86_64

COCOS2D-X-3.0 Official Edition

Apache-ant 1.9.3

Python 2.7 (Ubuntu comes with)

Adding environment variables

Export ANDROID_SDK_ROOT=/HOME/YANGMING/ADT-BUNDLE-LINUX/SDK
Export path=${path}:/$ANDROID _sdk_root/tools/
Export path=${path}:/$ANDROID _sdk_root/platform-tools/

Export ndk_root=/home/yangming/adt-bundle-linux/android-ndk-r9d
Export path=${path}:/$NDK _root


Export ant_root=/opt/apache-ant-1.9.3
Export path=${path}:/$ANT _root/bin.

The install-deps-linux.sh installed in the build directory under terminal to install the required environment such as GCC, there is a hard requirement, GCC at least 4.8,opengl at least 1.5. Below the standard may compile just go. Compilation was not done in the past.


Execute Setup.py,cocos new under terminal to create the project. The various platforms should be the same.

Get the folder you see


CD test/proj.linux/
Go to the Linuxproject folder and run
CMake.
Generates a makefile file.


Open Eclipse, import the Proj.linuxproject, select C + +, Select existing Code as Makefile Project, choose Linux gcc

At this point the project has been able to compile and execute directly, but the source code is not visible outside the folder. Let's introduce the source code again.

Right-click project->properties->c/c++ general->paths and Symbols->source Location->link Folder, Import the classes,resources,cocos2d in the project folder in turn. Cocos2d because there is a folder with the same name in Linuxproject. Be able to change a name

This is what project should look like today. Open a file and find that there are very many errors,

Take a look at the cause of the error, taking this director for example, we opened his head file and found Cc_dll this macro was not recognized


Where is this macro defined? In the respective CCPlatformDefine.h of each platform.

can see, because

#if Cc_target_platform = = Cc_platform_linux

was not established, resulting in the contents of this file are all invalid. We can look for cc_target_platform. He is/test.linux/cocos2dsrc/cocos/base/ccplatformconfig.h. The number of each platform is listed in this file. The cc_target_platform is set to 0 first and then reset after the following inference. We saw that the Linux line was gray. is # if defined (LINUX) is not set up. We just need to add Linux and Cc_dll to paths and symbols. The Linux value is null for the 1,cc_dll value.





Managed Build Setting must be placed on GCC built-in Compiler Settings, in providers first cancel GCC built-in Compiler Settings, click Apply, Then select GCC built-in Compiler Settings, then apply, back to entries. Managed Build setting ran to GCC built-in Compiler settings.

Good. Now AppDelegate.cpp has no error. Most of the files are normal, but the other part of the file will be an error. For example HelloWorldScene.cpp

Menuitemimage this class error. We found MenuItemImage.h. Found function this line error, Std::function is c++11 characteristics. We need to have the CDT identify the c++11 feature.

Find the functional file, the problem here is similar to the above platform recognition problem, #if __cplusplus >= 201103L This inference is not established, __cplusplus this value is the default value of 199711L, we need to paths and Symbols joins __cplusplus=201103l, joins-std=c++11 at the same time ,

Here you can point export settings to XML, and the new project import will


OK, now the whole project is not an error, code hints can also be used normally. Let's order a little hammer build. Started compiling. In fact, this project will be able to compile after the completion of the makefile file, the above error is only the Eclipse CDT setup problem, not a real mistake.

After the compilation is successful, run as Local C + + application, select Mygame,

Success.

The self-built class needs to join in the CMakeLists.txt, once again execute cmake, generate makefile talent enough to compile

Set (game_src  proj.linux/main.cpp  classes/appdelegate.cpp  classes/helloworldscene.cpp)


other inexplicable errors, such as Return has value, in function returning void, must implement the inherited pure virtual method. Invalid arguments ' candidates is:, Member declaration not found and so on, please update the CDT to the latest version, after I update these errors are gone.

Ubuntu14.04+eclipse under the COCOS2D-X3.0 Official edition environment Construction

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.