BlackBerry 10: Getting the Cocos2d-x Hello World app to build


This article explains how to get the sample 'Hello World' project building in Cocos2d-x. I had some difficulty getting it to compile and run. My goal is to eventually port my game Pocket Bombs from iPhone to BBX. As the iOS version is written in cocos2d for iPhone I hope to be able to quickly port it over once I figure out the BlackBerry port of the API.

References:

 

How to get a Cocos2d-x Hello World project to build

I am using the BlackBerry 10 SDK Beta 3. YMMV if you use a newer/older version:

  1. If you don't already have it installed, install the BlackBerry NDK from RIM's Website
  2. Download & extract the archive from the download page
  3. Run the create-blackberry-project.vbs script and give the project a nameRunCreateProjectVbs.png

  4. Create a new workspace in the Momentics IDE (Eclipse for BB10)

  5. Copy over the cocos2dx and CocosDenshion projects to the workspace using Windows Explorer

  6. Copy over the project you created in step 2 into the workspace using Windows Explorer
    The reason why I have you manually copy these folders over is because I had issues when I tried to 'import and copy'  feature in the IDE

  7. From within the IDE, Go to File -> Import then select General -> Existing Projects into Workspace and import the Blackberry project files that are in your workspace. Please note that there are other projects in the list aside from blackberry that you do not need so you don't have to select them.
    ImportExistingProjects.png

  8. Build the cocos2dx project
  9. Build the CocosDenshion project
  10. Build your project

    If all goes well your project should be ready to run on your Dev Alpha device / Simulator. If, however, you get an error about FT_New_Face font ('FT_New_Face' is defined in DSO C:/bbndk_10_0_9/target_10_0_9_386/qnx6/armle-v7/usr/lib/libfreetype.so.1 so try adding it to the linker command line), continue on to Step 11

  11. Right-click on your Project and select Configure -> Add Libraries... and select Standard BlackBerry Platform Library
  12. From the available list, select Freetype2 finish the wizard and save/apply to your project
    FreeType2selected.png


  13. Right-click on your Project and select Properties -> C/C++ Build -> Settings -> Tool Settings Tab -> QCC Linker option -> Libraries
    LibrariesSettings.png

  14. Select the freetype2 library and edit it (button to edit is tiny and in the 'Libraries' header section of the window). Make sure to change it to read freetype (Drop the 2). The image above in 11 shows this already done. This is an important step or you'll see errors about lfreetype2 not being able to be linked

  15. Open the bar-descriptor.xml file and remove any line that looks like this: < asset path="libfreetype2.so" type="Qnx/Elf">lib/libfreetype2.so< /asset>. See this screenshot for an example of what should be removed:
    RemoveFromBarDescriptorXmlFile.png

 

At this point things should be building correctly for you. I was able to get the test project to work on my Dev Alpha device. Hopefully this is a solid platform for me to use to port PocketBombs to BBX. Given that RIM has invested som engineer time into the project I have some degree of confidence that it will meet my needs.