Tuesday, March 05, 2013

Cocos2dx Setup: Windows 7 Visual Studio and Eclipse

I have been working on building a cocos2dx application that runs on Windows 7 x64 in Visual Studio, Eclipse, iPhone and MacOS X.

I started with this setup guide:

I had to do a lot of installing ....
  • Cocos2d-2.0x (same download for Mac OS X and Win32)
  • NDK r8d on Mac OS X and Windows (different downloads for Mac OS X and Win32)
  • Newest ADT and Android SDK on Mac OS X and Windows (different downloads)
  • Native Development Tools -- Eclipse Plugin
  • Android Development Tools -- Eclipse Plugin
  • Cygwin on Windows (with : autoconf, automake, binutils, gcc-core, gcc-g++, gcc4-core, gcc4-g++, gdb, pcre, pcre-devel, gawk, make)
  • Visual Studio 2010 C++ Language Support
  • Eclipse CDT (C++ Development Tools)
  • Several Eclipse, Java, Windows and Mac OS X Updates along the way

In the end, I believe that the correct way to configure the application is to have a folder for the project and sub-folders as follows:
  • \cocos2d-2.0-x-2.0.4\TileMapGame\Classes
  • \cocos2d-2.0-x-2.0.4\TileMapGame\Resources
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.android
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.win32

You can get this far using two included .sh scripts
  • \cocos2d-2.0-x-2.0.4\create-android-project.bat
  • \cocos2d-2.0-x-2.0.4\create-android-project.sh

You will quickly notice that Cocos2d-2.0-x does not come with an easy facility to create an XCode project folder the way it does for Visual Studio and Eclipse.

To create the following folders I used Notepad2 and editing the .xcodeproj files
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.ios
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.mac
I started by copying over these folders
  • \cocos2d-2.0-x-2.0.4\samples\HelloCpp\proj.ios
  • \cocos2d-2.0-x-2.0.4\samples\HelloCpp\proj.mac
Then I made some important changes
  • Changed relative paths to 'cocos2dx.xcodeproj'
  • Renamed Project
  • Reconnected plist file
  • Fixed "Header Search Paths" to include correct relative paths
  • Converted "Resource" sub-folders to 'groups' by deleting and re-adding
  • Added CocosDenshion group and added 'ios' and 'include' folders
  • Added missing frameworks
    • AudioToolkit
    • OpenAL
    • AVFoundation
  • Set 'version' and deployment targets for iOS and Mac OS X

So at the end I have this structure
  • \cocos2d-2.0-x-2.0.4\TileMapGame\Classes
  • \cocos2d-2.0-x-2.0.4\TileMapGame\Resources
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.android
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.win32
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.ios
  • \cocos2d-2.0-x-2.0.4\TileMapGame\proj.mac
The only two I have not created are 'proj.linux' and 'proj.blackberry' because at this time I do not have any need for them.

I used the following pages for debugging and troubleshooting:



2 comments:

Unknown said...

Wow, nice post! And both the links in the section "Dealing with file not found when attempting to debug in XCode (happens a lot)" refers me :)

reflute said...

Your blog has been very helpful. Thanks for the assistance.