操作系统:Windows7(64-bit)
VS版本:2013
Cocos2d-x版本:3.0
工程路径:E:\cocos2d-prj\
1.从github下载libpomelo代码
E:\cocos2d-prj\cocos2d\external> git clone https://github.com/NetEase/libpomelo.git
2.创建libpomelo的VS工程
E:\cocos2d-prj\cocos2d\external>cd libpomelo E:\cocos2d-prj\cocos2d\external\libpomelo>mkdir build E:\cocos2d-prj\cocos2d\external\libpomelo>git clone https://github.com/martine/gyp.git build/gyp E:\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的VS工程(执行E:\cocos2d-prj\libpomelo\deps\uv\vcbuild.bat脚本即可)
E:\cocos2d-prj\cocos2d\external>cd libpomelo\deps\uv E:\cocos2d-prj\cocos2d\external\libpomelo\deps\uv>vcbuild.bat
4.打开cocos2d工程,将下列vs项目加入工程(add existing project)
E:\cocos2d-prj\cocos2d\external\libpomelo\libpomelo.vcxproj E:\cocos2d-prj\cocos2d\external\libpomelo\deps\jansson\jansson.vcxproj E:\cocos2d-prj\cocos2d\external\libpomelo\deps\uv\libuv.vcxproj5.修改工程版本
vs中右键上述工程,选择菜单 Upgrade VC++ Compiler and Libraries
6.添加工程依赖
在cocos2d-prj工程上邮件,选择 属性 菜单项,将上述三个工程添加为依赖,如下图
7.添加Include
8.添加系统lib引用Psapi.lib;Iphlpapi.lib;,如下图
操作系统:Windows7(64-bit)
NDK版本:r9d (64-bit)
Cocos2d-x版本:3.0
工程路径:E:\cocos2d-prj\
Android平台相对简单,只要修改E:\cocos2d-prj\proj.android\jni\Android.mk文件就可以了,总共三处如下图
操作系统: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
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
在"Build Settings" 的 “Header Search Paths” 里加入三个目录:
libpomelo/include
libpomelo/deps/jansson/src
libpomelo/deps/uv/include
注意目录的绝对和相对位置
这样就可以同时在真机和模拟器里调用libpomelo静态库了。