Ubuntu14.04+eclipse under the cocos2d-x3.6 Official edition environment Construction

Source: Internet
Author: User

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.
Terminal under the Run Build folder install-deps-linux.sh install GCC and other compilation required environment, here are hard requirements, gcc at least 4.8,opengl at least 1.5, below the standard may not compile, compile in the past can not run.

Run Setup.py,cocos new on the terminal to create the project, which should all be the same for each platform.
Get Catalog

Copy Code
  1. CD test/proj.linux/


Enter the Linux project directory and execute

Copy Code
  1. CMake.


Generate a Makefile file,

open Eclipse, import the Proj.linux project, select C + +, Select existing Code as Makefile project, choose Linux gcc



At this time the project can be directly compiled and run, but the source code is not visible outside the directory, we will introduce the source code.
Right-click the project->properties->c/c++ general->paths and Symbols->source location->link Folder, and then import the classes in the project catalog , resources,cocos2d. Cocos2d because there is a directory with the same name in Linux project, you can change the name

now the project should be like this, open a file and find a lot of 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,

as can be seen, because # if cc_target_platform = = Cc_platform_linux is not established, resulting in the contents of this file are all invalid, we can find Cc_target_platform, he in/test.linux/ Cocos2dsrc/cocos/base/ccplatformconfig.h, this file lists the number of each platform, Cc_target_platform is set to 0, and then reset after the following judgment, we see the Linux line is gray, is the # If defined (Linux) is not established, we only need to add the LINUX parameter in paths and symbols and the Cc_dll,linux value to the 1,cc_dll value is empty,

,

The managed Build Setting must be placed above the 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


OK, now AppDelegate.cpp no error, most of the files are normal, but there are still a small number of errors, such as HelloWorldScene.cpp

Menuitemimage This class error, we find MenuItemImage.h, find function This line error, Std::function is c++11 feature, we need to let CDT identify c++11 characteristics.

find the functional file, the problem here is similar to the above platform recognition problem, #if __cplusplus >= 201103L This judgment is not established, __cplusplus this value default is 199711L, we need to paths and symbols add __cplusplus=201103l, add-std=c++11,
Here you can click Export Settings exporting Settings to XML, the new project import can be

OK, now the whole project is not error, code hints can also be used normally. We set a little hammer build and started compiling. In fact, this project generated after the makefile file can be compiled normally, the above error is only eclipse CDT setup problem, not a real error.

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

Success!

self-built classes need to be added in CMakeLists.txt, rerun CMake, generate makefile to compile

copy code
  1. set (game_src  
  2.       PROJ.L inux/main.cpp  
  3.       classes/appdelegate.cpp  
  4.       classes/helloworldscene.cpp  
  5.     )   



Android programmers, used to eclipse, with a variety of uncomfortable ah, send a tutorial, hoping to expand the Eclipse and Linux users


There are also some inexplicable errors, such as Return has value, in function returning void, must implement the inherited pure virtual Method,invali D arguments ' candidates is:, Member declaration not found and so on, please update the CDT to the latest version, after I update these errors have disappeared

Ubuntu14.04+eclipse under the cocos2d-x3.6 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.