Windows平台
操作系统:Windows7(64-bit)
VS版本号:2013
Cocos2d-x版本号:3.0
project路径:E:\cocos2d-prj\
1.从github下载libpomelo代码
E:\cocos2d-prj\cocos2d\external> git clone https://github.com/NetEase/libpomelo.git
2.创建libpomelo的VSproject
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
假设遇到报错(一个VS版本号问题)
改动E:\snake\code\client\libpomelo\build\gyp\pylib\gyp\MSVSVersion.py文件第188行
return versions[str(name)]
改为
return versions[“2010”]
改动后继续运行脚本E:\cocos2d-prj\cocos2d\external\libpomelo>build\gyp\gyp.bat --depth=. pomelo.gyp -Dlibrary=static_library -DTO=pc
3.创建libuv的VSproject(运行E:\cocos2d-prj\libpomelo\deps\uv\vcbuild.bat脚本就可以)
E:\cocos2d-prj\cocos2d\external>cd libpomelo\deps\uvE:\cocos2d-prj\cocos2d\external\libpomelo\deps\uv>vcbuild.bat
4.打开cocos2dproject。将下列vs项目增加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.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-prj\proj.android\jni\Android.mk文件就能够了。总共三处例如以下图
IOS平台
操作系统:MAC MINI
XCODE版本号:3.1.1
iphonesimulator : 6.1
Cocos2d-x版本号:3.0
Python : 2.7
gyp工具
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=ios2.生成静态库
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
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.a4.改动xcodeproject
在"Build Settings" 的 “Header Search Paths” 里增加三个文件夹:
libpomelo/include
libpomelo/deps/jansson/src
libpomelo/deps/uv/include
注意文件夹的绝对和相对位置
这样就能够同一时候在真机和模拟器里调用libpomelo静态库了。
版权声明:本文博客原创文章,博客,未经同意,不得转载。