1
votes

I've been going at this problem for almost a week now and I still have 700+ errors. Definitely need all your help! Thanks.

Problem: Need to use

Cocos2dx for Windows Phone 8

in my C++/DirectX Visual Studio 2012 project that also uses C#/XAML UI.

Given: Cocos2dx-wp8 as an Application .exe project downloaded from http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Download

Solution:

  1. Open my C#/XAML/DirectX Game1 solution .sln project in Visual Studio 2012.
  2. Right click on solution in Solution Explorer. Add --> Existing Project...
  3. Selected: \cocos2dx-0.13.0-wp8-0.8\HelloWorld\cocos2d.vcxproj and clicked open
  4. Renamed the HelloWorld project to something else like "Cocos2dxWp8" and delete the HelloWorld Classes folder and all the Assets you don't want (like the squirrels and background images)
  5. Click Properties --> Configuration Properties --> General --> Configuration Type --> from "Application (.exe) change to "Dynamic Library (.dll)"

  6. Added new paths to Properties --> C/C++ --> Additional Include Directories -->

$(ProjectDir); $(IntermediateOutputPath); ..\cocos2dx\include; ..\cocos2dx; ..\cocos2dx\platform\third_party\win8_metro\libpng; ..\cocos2dx\platform\third_party\win8_metro\zlib; ..\cocos2dx\platform\third_party\win8_metro; ....\Cocos2dxWp8; ..\cocos2dx\platform\win8_metro; ..\cocos2dx\platform\third_party\win8_metro\freetype; ..\cocos2dx\platform\third_party\win8_metro\libjpeg; ..\CocosDenshion\include; ..\cocos2dx\platform; inc; %(AdditionalIncludeDirectories)

  1. Updated the paths in Properties --> Linker --> Input --> Additional Dependencies -->

..\cocos2dx\platform\third_party\win8_metro\libraries\x86\freetype.lib; ..\cocos2dx\platform\third_party\win8_metro\libraries\x86\zlib.lib; ..\cocos2dx\platform\third_party\win8_metro\libraries\x86\libjpeg.lib; ..\cocos2dx\platform\third_party\win8_metro\libraries\x86\libpng.lib; dxguid.lib;xaudio2.lib;dxgi.lib;uuid.lib;d3d11.lib;%(AdditionalDependencies)

  1. Updated paths in VC++ Directories:

$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\freetype; $(SolutionDir); $(ProjectDir)inc; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\CocosDenshion\include; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\zlib; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libraries; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libpng; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libjpeg; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libxml2; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\win8_metro; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\include; $(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx; $(IncludePath)

From here, it builds successfully! It outputs a .dll file but no .lib file, so...

  1. In CCPlatformMacros.h, I enabled exporting classes to dll:

    #define CC_DLL __declspec(dllexport)

Yah, .lib is being written to then...

715 Errors, 772 Warnings

Error 773 error LNK2001: unresolved external symbol "public: virtual __thiscall cocos2d::CCKeypadHandler::~CCKeypadHandler(void)" (??1CCKeypadHandler@cocos2d@UAE@XZ) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCSpriteBatchNode.obj Cocos2dXWp8Framework Error 774 error LNK2001: unresolved external symbol "public: virtual __thiscall cocos2d::CCKeypadHandler::~CCKeypadHandler(void)" (??1CCKeypadHandler@cocos2d@UAE@XZ)

I've included the header file for where CCKeyHandler class is defined (inside CCKeypadDelegate.h) and CCSpriteBatchNode.h is also in the same include folder.

Class signatures look like this:

class CC_DLL CCKeypadHandler : public CCObject
class CC_DLL CCSpriteBatchNode : public CCNode, public CCTextureProtocol

Errors continue as is...

F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2dorig.obj Cocos2dXWp8Framework Error 775 error LNK2001: unresolved external symbol "public: virtual __thiscall cocos2d::CCKeypadHandler::~CCKeypadHandler(void)" (??1CCKeypadHandler@cocos2d@@UAE@XZ) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCImage_win8_metro.obj Cocos2dXWp8Framework

...

Error 1482 error LNK2001: unresolved external symbol "public: virtual void __thiscall cocos2d::CCTMXMapInfo::textHandler(void *,char const *,int)" (?textHandler@CCTMXMapInfo@cocos2d@UAEXPAXPBDH@Z) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCDrawingPrimitives.obj Cocos2dXWp8Framework Error 1483 error LNK2001: unresolved external symbol "public: virtual void __thiscall cocos2d::CCTMXMapInfo::textHandler(void *,char const *,int)" (?textHandler@CCTMXMapInfo@cocos2d@UAEXPAXPBDH@Z) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2d.obj Cocos2dXWp8Framework Error 1484 error LNK2019: unresolved external symbol "public: virtual __thiscall cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)" (??1CCKeypadDispatcher@cocos2d@UAE@XZ) referenced in function "public: virtual void * __thiscall cocos2d::CCKeypadDispatcher::`vector deleting destructor'(unsigned int)" (??_ECCKeypadDispatcher@cocos2d@UAEPAXI@Z) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCDirector.obj Cocos2dXWp8Framework Error 1485 error LNK2001: unresolved external symbol "public: virtual __thiscall cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)" (??1CCKeypadDispatcher@cocos2d@UAE@XZ) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCLayer.obj Cocos2dXWp8Framework Error 1486 error LNK2001: unresolved external symbol "public: virtual __thiscall cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)" (??1CCKeypadDispatcher@cocos2d@UAE@XZ) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCEGLView_win8_metro.obj Cocos2dXWp8Framework Error 1487 error LNK1120: 48 unresolved externals F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\Win32\Debug\cocos2d\Cocos2dXWp8Framework.dll Cocos2dXWp8Framework

Solution / Project paths:

F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx.sln F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\GameWp8Dx\GameWp8Dx.csproj F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\GameWp8DxComponent\GameWp8DxComponent.vcxproj F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2d.vcxproj

Cocos2d Include files:

F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\cocos2dx\include F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\cocos2dx\platform

Object files built here:

F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\Win32\Debug*.obj

.dll / .lib built here:

F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\Win32\Debug\cocos2d

Sorry for the long post, but I hope that's enough details to get this question going. Thanks.

2
This solution you're trying to build, it's one project that contains all the logic and the GUI both?evanmcdonnal
@evanmcdonnal Hi, I have GameWp8Dx.sln, open it up, it has: GameWp8Dx.csproj (C#/XAML WP8 application, startup project, this is the GUI), GameWp8DxComponent.vcxproj (C++/DirectX project), and cocos2d.vcxproj (the one I'm trying to build right now. Eventually,I'm going add the cocos2d project as "Add New Reference" to the DirectX project.Lisa
cocos2d should already be building as a dll if it's not the start up project. Can you build the entire solution? If so, the dll you want to use will be somewhere in the drop folder.evanmcdonnal
@evanmcdonnal I downloaded the Windows Phone 8 version of cocos2dx. I unzipped the file, and built the project. Then did I search for the .dll, but no .dll or .lib appeared. What do I need for it to show up? Thx.Lisa
Are you searching for cocos2dx.dll? That's not going to be there. The dll you're looking for would go by a different name. There are some dll's, right?evanmcdonnal

2 Answers

1
votes

I created a new dynamic library project, then copied over the files. I got the .dll and .lib built, but didn't work for an ARM CPU build target (used for devices). Also, the setup for the Cocos2dx director and scene layer doesn't seem to work well with an existing C#/XAML with DirectX project that renders onto a DrawingSurfaceBackgroundGrid control. So at the end, I didn't end up using Cocos2dx in my mixed project setup.

If anyone else got better suggestions, please let me know. Thanks.

0
votes

ON TOPIC: Perhaps you did not properly set project dependencies inside your SLN ?

I got Cocos2d to partially work with XAML+D3d Interop, but because calls go back and forward from the XAMLComponent DLL to the Cocos2d DLL, it seems to be messing up pointers and memory. Right now I tried to move all Cocos2D source files to my D3Dcomponent project, but something is terribly wrong, and I get a weird kernelbase.dll first chance exception.

OFF TOPIC: I was also trying to put a game done over cocos2d-x on an XAML+D3D Interop project, and used the template that comes with Visual Studio 2012. However, only a smudgy background was displayed. I was using DrawingSurfaceBackgroundGrid, and found out later that on Windows Phone 8, it has some issues related to Z-order. I ended up replacing it with DrawingSurface.