本文描述cocos2d-x 3.x版本的windows xp版本,即完美在xp系统上运行。

必备:

vs2013 update5 vs2015 update3,笔者系统win10 x64系统
cocos2d-x 3.X版本,已成功运行起来的的版本有3.4 3.5 3.10 3.13版本,其他版没试验,都很类似的修改。

libcocos2d项目属性修改

编译发布版的Release

添加预编译宏

项目菜单->项目属性->配置属性->C/C++->预编译
WIN32_WINNT=0x0501

添加链接库

项目菜单->项目属性->配置属性->链接->输入
user32.lib
gdi32.lib
advapi32.lib
Shell32.lib
ws2_32.lib

cocos2d-x源代码修改:

5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(47): error C2065: 'LPWSAPOLLFD' : undeclared identifier (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(47): error C2146: syntax error : missing ')' before identifier 'fdarray' (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(47): error C2165: 'left-side modifier' : cannot modify pointers to data (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(47): error C2513: 'INT *' : no variable declared before '=' (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(47): error C2059: syntax error : ')' (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(50): error C2065: 'LPWSAPOLLFD' : undeclared identifier (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(50): error C2146: syntax error : missing ')' before identifier 'fdarray' (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(50): warning C4229: anachronism used : modifiers on data are ignored (..networkWebSocket.cpp)
5>e:sdkcocos2d-x-cocos2d-x-3.10externalwebsocketsincludewin32win32helpers/websock-w32.h(50): error C2059: syntax error : ')' (..networkWebSocket.cpp)

直接注释掉

5>..baseCCConsole.cpp(412): error C3861: 'inet_pton': identifier not found
5>..baseCCConsole.cpp(417): error C3861: 'inet_pton': identifier not found
5>..baseCCConsole.cpp(443): error C3861: 'inet_ntop': identifier not found
5>..baseCCConsole.cpp(450): error C3861: 'inet_ntop': identifier not found

同样注释掉,如果你要用到就自己重写net_ntop函数,网上有教程。

依赖库修改

3.4 3.5版这一步直接跳过
xp错误的提示:InitializeCriticalsectionEx,
curl新版库用了函数,xp系统是没的,删除curl文件夹,再放旧版的,这里下载:http://pan.baidu.com/s/1mhvjlHm
cocos2d-x 3.13删除替换 webp :http://pan.baidu.com/s/1qYLA1ti

编译说明&vs运行库安装

Release每次都会重新编译
1、C/C++  -> Genera -> Debug Information Format: Program Database for Edit & Continue (/ZI), 或者 Program Database (/Zi) ,或者删除None
2、在你工程加入链接库libcocos2d.lib,移除掉libcocos2d的依赖项目
除了f#不用装,都勾上下载地址:http://pan.baidu.com/s/1c1e4ALq ,注意如果是2015安装:https://www.microsoft.com/en-hk/download/details.aspx?id=48145

总结

同样如果你想编译xp项目,也可以做参考,特别是要指定WIN32_WINNT=0x0501。
项目菜单->项目属性->配置属性->常规->平台工具集,选择“VS2013WindowsXP(v120_xp)”。
项目菜单->项目属性->配置属性->链接->系统->5.01
提示不是有效的应用程序,一般是缺少运行库。
提示无法定位程序输入点 xxx 于动态链接库XX上的,就要检查你源代码或者依赖的库里面有XP不存在函数,把函数移除,或重写。

《Cocos2d-x在XP上完美运行》