Windows平台
操作系统:Windows7(64-bit)
VS版本号:2013
Cocos2d-x版本号:3.0
project路径:E:cocos2d-prj
1.从github下载libpomelo代码
E:cocos2d-prjcocos2dexternal> git clone https://github.com/NetEase/libpomelo.git
2.创建libpomelo的VSproject
E:cocos2d-prjcocos2dexternal>cd libpomelo E:cocos2d-prjcocos2dexternallibpomelo>mkdir build E:cocos2d-prjcocos2dexternallibpomelo>git clone https://github.com/martine/gyp.git build/gyp E:cocos2d-prjcocos2dexternallibpomelo>buildgypgyp.bat --depth=. pomelo.gyp -Dlibrary=static_library -DTO=pc
假设遇到报错(一个VS版本号问题)
改动E:snakecodeclientlibpomelouildgyppylibgypMSVSVersion.py文件第188行
return versions[str(name)]
改为
return versions[“2010”]
E:cocos2d-prjcocos2dexternallibpomelo>buildgypgyp.bat --depth=. pomelo.gyp -Dlibrary=static_library -DTO=pc
3.创建libuv的VSproject(运行E:cocos2d-prjlibpomelodepsuvvcbuild.bat脚本就可以)
E:cocos2d-prjcocos2dexternal>cd libpomelodepsuv E:cocos2d-prjcocos2dexternallibpomelodepsuv>vcbuild.bat
4.打开cocos2dproject。将下列vs项目增加project(add existing project)
E:cocos2d-prjcocos2dexternallibpomelolibpomelo.vcxproj E:cocos2d-prjcocos2dexternallibpomelodepsjanssonjansson.vcxproj E:cocos2d-prjcocos2dexternallibpomelodepsuvlibuv.vcxproj5.改动project版本号
vs中右键上述project。选择菜单 Upgrade VC++ Compiler and Libraries
6.加入project依赖
在cocos2d-prjproject上邮件,选择 属性 菜单项,将上述三个project加入为依赖,例如以下图
7.加入Include
8.加入系统lib引用Psapi.lib;Iphlpapi.lib;。例如以下图
Android平台
操作系统:Windows7(64-bit)
NDK版本号:r9d (64-bit)
Cocos2d-x版本号:3.0
project路径:E:cocos2d-prj
Android平台相对简单,仅仅要改动E:cocos2d-prjproj.androidjniAndroid.mk文件就能够了。总共三处例如以下图
IOS平台
操作系统:MAC MINI
XCODE版本号:3.1.1
iphonesimulator : 6.1
Cocos2d-x版本号:3.0
Python : 2.7
gyp工具
cd pomelo gyp --depth=. pomelo.gyp -Dlibrary=static_library -DTO=ios cd deps/uv gyp --depth=. uv.gyp -Dlibrary=static_library -DTO=ios cd ../jansson gyp --depth=. jansson.gyp -Dlibrary=static_library -DTO=ios
2.生成静态库
cd pomelo xcodebuild -project deps/jansson/jansson.xcodeproj xcodebuild -project deps/uv/uv.xcodeproj xcodebuild -project pomelo.xcodeproj xcodebuild -project deps/jansson/jansson.xcodeproj -sdk iphonesimulator6.1 -arch i386 xcodebuild -project deps/uv/uv.xcodeproj -sdk iphonesimulator6.1 -arch i386 xcodebuild -project pomelo.xcodeproj -sdk iphonesimulator6.1 -arch i386
cd pomelo lipo -create ./build/Default-iphoneos/libpomelo.a ./build/Default-iphonesimulator/libpomelo.a -output libpomelo.a lipo -create ./deps/jansson/build/Default-iphoneos/libjansson.a ./deps/jansson/build/Default-iphonesimulator/libjansson.a -output libjansson.a lipo -create ./deps/uv/build/Default-iphoneos/libuv.a ./deps/uv/build/Default-iphonesimulator/libuv.a -output libuv.a
4.改动xcodeproject
在"Build Settings" 的 “Header Search Paths” 里增加三个文件夹:
libpomelo/include
libpomelo/deps/jansson/src
libpomelo/deps/uv/include
注意文件夹的绝对和相对位置
这样就能够同一时候在真机和模拟器里调用libpomelo静态库了。
版权声明:本文博客原创文章,博客,未经同意,不得转载。