Teach you how to add libpomelo to cocos2d-x projects (Windows, Android, IOS platforms), libpomelococos2d-x

Source: Internet
Author: User

Teach you how to add libpomelo to cocos2d-x projects (Windows, Android, IOS platforms), libpomelococos2d-x
Windows Platform

Operating System: Windows 7 (64-bit)

VS: 2013

Cocos2d-x version: 3.0

Project path: E: cocos2d-prj \


1. Download libpomelo code from github

E:\cocos2d-prj\cocos2d\external> git clone https://github.com/NetEase/libpomelo.git


2. Create a VS project for libpomelo

E:\cocos2d-prj\cocos2d\external>cd libpomeloE:\cocos2d-prj\cocos2d\external\libpomelo>mkdir buildE:\cocos2d-prj\cocos2d\external\libpomelo>git clone https://github.com/martine/gyp.git build/gypE:\cocos2d-prj\cocos2d\external\libpomelo>build\gyp\gyp.bat --depth=. pomelo.gyp -Dlibrary=static_library -DTO=pc

 
 

If an error is reported (a vs version problem)

Modify row 188th of the E: \ snake \ code \ client \ libpomelo \ build \ gyp \ pylib \ gyp \ MSVSVersion. py file

Return versions [str (name)]

Change

Return versions ["2010"]

Execute the script after modification.

E:\cocos2d-prj\cocos2d\external\libpomelo>build\gyp\gyp.bat --depth=. pomelo.gyp -Dlibrary=static_library -DTO=pc 

 

3. Create libuv VS Project (execute E: \ cocos2d-prj \ libpomelo \ deps \ uv \ vcbuild. bat script)

E:\cocos2d-prj\cocos2d\external>cd libpomelo\deps\uvE:\cocos2d-prj\cocos2d\external\libpomelo\deps\uv>vcbuild.bat
 

4. Open the cocos2d project and add the following vs projects to the project (add existing project)

E:\cocos2d-prj\cocos2d\external\libpomelo\libpomelo.vcxprojE:\cocos2d-prj\cocos2d\external\libpomelo\deps\jansson\jansson.vcxprojE:\cocos2d-prj\cocos2d\external\libpomelo\deps\uv\libuv.vcxproj

 

5. Modify the project version

In vs, right-click the above project and select Upgrade VC ++ Compiler and Libraries

6. Add project Dependencies

On the cocos2d-prj project, select the properties menu item to add the three projects as dependencies, as shown in

7. Add Include

8. Add the system lib to reference Psapi. lib; Iphlpapi. lib;, as shown in figure

Android platform

Operating System: Windows 7 (64-bit)

NDK version: r9d (64-bit)

Cocos2d-x version: 3.0

Project path: E: cocos2d-prj \

Android platform is relatively simple, as long as you modify E: \ cocos2d-prj \ proj. android \ jni \ Android. mk file can be, a total of three such

IOS platform

Operating System: MAC MINI

XCODE version: 3.1.1

Iphonesimulator: 6.1

Cocos2d-x version: 3.0

Python: 2.7.

Gyp Tool

1. Create an xcode project and run the following command:
cd pomelogyp --depth=. pomelo.gyp -Dlibrary=static_library -DTO=ioscd deps/uvgyp --depth=. uv.gyp -Dlibrary=static_library -DTO=ioscd ../janssongyp --depth=. jansson.gyp -Dlibrary=static_library -DTO=ios

2. Generate a static library
cd pomeloxcodebuild -project deps/jansson/jansson.xcodeprojxcodebuild -project deps/uv/uv.xcodeprojxcodebuild -project pomelo.xcodeprojxcodebuild -project deps/jansson/jansson.xcodeproj -sdk iphonesimulator6.1 -arch i386xcodebuild -project deps/uv/uv.xcodeproj -sdk iphonesimulator6.1 -arch i386xcodebuild -project pomelo.xcodeproj -sdk iphonesimulator6.1 -arch i386

3. Use lipo to package the two together
cd pomelolipo -create ./build/Default-iphoneos/libpomelo.a  ./build/Default-iphonesimulator/libpomelo.a  -output libpomelo.alipo -create ./deps/jansson/build/Default-iphoneos/libjansson.a ./deps/jansson/build/Default-iphonesimulator/libjansson.a  -output libjansson.alipo -create ./deps/uv/build/Default-iphoneos/libuv.a ./deps/uv/build/Default-iphonesimulator/libuv.a  -output libuv.a

4. Modify the xcode Project
Open the cocos2d-x project in xcode and add the three. a static library files generated in project target Build Phases to "Link Binary With Libraries;

Add three directories to "Header Search Paths" in "Build Settings:

Libpomelo/include

Libpomelo/deps/jansson/src

Libpomelo/deps/uv/include

Note the absolute and relative locations of directories.

In this way, you can call the libpomelo static library in both the real machine and simulator.




Cocos2d-x 32alpha Lua project created in android platform cannot be transplanted Problems

When Cocos 3.0 creates the default Lua project, its Android project is very incomplete. The generated project template. C ++ compilation is not included at all.
Your exception actually tells you that the SO file is not generated in the libs directory of your project.
I also tried to modify the default Android Project template in the past, but the modification volume was too large, and it took a long time to complete the modification.
My advice to you is not to use Cocos to create a Lua project. Just create a common C ++ project. After compiling a common C ++ project, you can get the SO library under the libs directory.
For Android Lua projects, it does not need C ++ code, but a SO library file,
With this SO library file, the rest is easy to handle.
 
Cocos2d-x on windows write code compiled into android version running on the real machine debugging, Get data from file (assets/) failed!

This is a bug in cocos2d-x. Switch to cocos2d-x 0.12.0 just fine. Some problems are inevitable in beta

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.