cocos2d-x-2.1.4用VS2010编译示例失败

1.点击cocos2d-win32.vc2010.sln将cocos2d-x导入VS2010中生成解决方案,然后经过漫长的编译之后,编译器会告诉你有两个项目编译失败了。这两个失败的项目是WatermelonWithMe和CocosDragonJS。

下面是单独编译Watermelon所打印的调试信息。

1>------ Build started: Project: libcocos2d, Configuration: Debug Win32 ------
2>------ Build started: Project: libchipmunk, Configuration: Debug Win32 ------
1>Build started 2013/8/1 14:00:39.
2>Build started 2013/8/1 14:00:39.
1>InitializeBuildStatus:
1>  Creating "Debug.win32\libcocos2d.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>InitializeBuildStatus:
2>  Creating "Debug.win32\libchipmunk.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>ClCompile:
2>  All outputs are up-to-date.
2>Lib:
2>  All outputs are up-to-date.
2>  chipmunk.vcxproj -> E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\libchipmunk.lib
2>FinalizeBuildStatus:
2>  Deleting file "Debug.win32\libchipmunk.unsuccessfulbuild".
2>  Touching "Debug.win32\libchipmunk.lastbuildstate".
2>
2>Build succeeded.
2>
2>Time Elapsed 00:00:00.17
1>ClCompile:
1>  All outputs are up-to-date.
1>  All outputs are up-to-date.
1>PreLinkEvent:
1>  复制了 15 个文件
1>Link:
1>  All outputs are up-to-date.
1>  cocos2d.vcxproj -> E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\libcocos2d.dll
1>FinalizeBuildStatus:
1>  Deleting file "Debug.win32\libcocos2d.unsuccessfulbuild".
1>  Touching "Debug.win32\libcocos2d.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:02.51
3>------ Build started: Project: libCocosDenshion, Configuration: Debug Win32 ------
3>Build started 2013/8/1 14:00:42.
3>InitializeBuildStatus:
3>  Creating "Debug.win32\libCocosDenshion.unsuccessfulbuild" because "AlwaysCreate" was specified.
3>ClCompile:
3>  All outputs are up-to-date.
3>Link:
3>  All outputs are up-to-date.
3>  CocosDenshion.vcxproj -> E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\libCocosDenshion.dll
3>FinalizeBuildStatus:
3>  Deleting file "Debug.win32\libCocosDenshion.unsuccessfulbuild".
3>  Touching "Debug.win32\libCocosDenshion.lastbuildstate".
3>
3>Build succeeded.
3>
3>Time Elapsed 00:00:00.11
4>------ Build started: Project: libExtensions, Configuration: Debug Win32 ------
4>Build started 2013/8/1 14:00:42.
4>InitializeBuildStatus:
4>  Creating "Debug.win32\libExtensions.unsuccessfulbuild" because "AlwaysCreate" was specified.
4>ClCompile:
4>  All outputs are up-to-date.
4>Lib:
4>  All outputs are up-to-date.
4>  libExtensions.vcxproj -> E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\libExtensions.lib
4>FinalizeBuildStatus:
4>  Deleting file "Debug.win32\libExtensions.unsuccessfulbuild".
4>  Touching "Debug.win32\libExtensions.lastbuildstate".
4>
4>Build succeeded.
4>
4>Time Elapsed 00:00:00.35
5>------ Build started: Project: libJSBinding, Configuration: Debug Win32 ------
5>Build started 2013/8/1 14:00:42.
5>InitializeBuildStatus:
5>  Creating "Debug.win32\libJSBinding.unsuccessfulbuild" because "AlwaysCreate" was specified.
5>PreBuildEvent:
5>  复制了 2 个文件
5>ClCompile:
5>  All outputs are up-to-date.
5>Lib:
5>  All outputs are up-to-date.
5>  libJSBinding.vcxproj -> E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\libJSBinding.lib
5>FinalizeBuildStatus:
5>  Deleting file "Debug.win32\libJSBinding.unsuccessfulbuild".
5>  Touching "Debug.win32\libJSBinding.lastbuildstate".
5>
5>Build succeeded.
5>
5>Time Elapsed 00:00:06.15
6>------ Build started: Project: WatermelonWithMe, Configuration: Debug Win32 ------
6>Build started 2013/8/1 14:00:49.
6>InitializeBuildStatus:
6>  Creating "Debug.win32\WatermelonWithMe.unsuccessfulbuild" because "AlwaysCreate" was specified.
6>PreBuildEvent:
6>  Description: Copy js and resource files.
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_chipmunk.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_chipmunk_constants.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_cocos2d.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_cocos2d_constants.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_cocos2d_extension.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_cocosbuilder.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_debugger.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_opengl.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_opengl_constants.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\jsb_sys.js
6>  E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\main.debug.js
6>  复制了 12 个文件
6>  复制了 0 个文件
6>  找不到文件 - WatermelonWithMe
6>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(103,5): error MSB3073: The command "if not exist "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\" mkdir "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\"
6>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(103,5): error MSB3073: if exist "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\\WatermelonWithMeRes" rd /s /q "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\\WatermelonWithMeRes"
6>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(103,5): error MSB3073: mkdir "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\\WatermelonWithMeRes"
6>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(103,5): error MSB3073: xcopy "E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\..\..\scripting\javascript\bindings\js\*.js" "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\\WatermelonWithMeRes" /e /Y
6>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(103,5): error MSB3073: xcopy "E:\file\visual studio 2010\cocos2d-x-2.1.4\samples\Javascript\WatermelonWithMe\proj.win32\..\..\Shared\games\WatermelonWithMe" "E:\file\visual studio 2010\cocos2d-x-2.1.4\Debug.win32\\WatermelonWithMeRes\" /e /Y     //查看这里
6>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(103,5): error MSB3073: :VCEnd" exited with code 4.
6>
6>Build FAILED.
6>
6>Time Elapsed 00:00:00.44
========== Build: 5 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

看到编译终止时的那条信息,发现拷贝目录Shared\games 下面的WatermelonWithMe的时候出现了错误。在看cocos2d-x相应的目录结构中才发现它缺少了WatermelonWithMe文件夹,所以拷贝时出现了错误。查看同级目录下的相关目录,推测这个目录里面应该包含一些资源和入口的js文件。对应于WatermelonWithMe项目的入口js文件(ScriptingCore::getInstance()->runScript("boot-jsb.js");)boot-jsb.js本应该在这个缺失的目录中。

所以当MoonWarriors和CrystalCraze两个示例游戏在这个目录下相应的文件没有缺失时它们是可以编译成功且能运行的。

而WatermelonWithMe和CocosDragonJS两个就失败了。

解决的方法是在Shared\games中创建WatermelonWithMe和CocosDragonJS两个目录,这样编译的时候就不会因为缺失这两个文件夹而出现拷贝错误。当然这样只是治标不治本的一种做法,因为缺失必要的游戏代码文件,就算是编译通过了,运行程序只能看到一个漆黑的窗口。

你可能感兴趣的:(cocos2d-x,开发)