Adding the BlackBerry C/C++ Native Target in 48 Hours

I am one of the lead developers for NME, a cross-platform, open-source framework.

If you have not heard of NME, it targets Windows, Mac, Linux, iOS, Android, BlackBerry, webOS, Flash and HTML5 from a single codebase. It does not require a virtual machine, and does not use a scripting language like Lua or Javascript, other than the HTML5 target. It reliably supports each platform using native C++ and OpenGL, SWF bytecode or Javascript, thanks to the incredible Haxe programming language.

The BlackBerry target is the newest platform we support. It took me less than two days to add.

We use a library called Simple DirectMedia Layer (SDL), which makes it much simpler to support multiple platforms. We use SDL for our desktop targets, as well as webOS and BlackBerry.

The first thing I needed to do was download and install the BlackBerry Native SDK.

Since I decided to use SDL in order to support BlackBerry, I used our webOS target as the basis for adding the platform. Since the Native SDK includes GCC, it did not take very much to modify our webOS toolchain settings in order to support BlackBerry.

We use a build tool that accepts XML-based settings for each compiler toolchain. Even though this is probably different than what you may use to compile C/C++ code, it should be simple to understand.

Once our code was compiling, I was able to check out the BlackBerry SDL project and compile it using the Momentics IDE that is included with the Native SDK. If you would prefer, you can also download the binaries I have already compiled for NME.

In addition to the ordinary “-lSDL” flag, we are also linking “-lbps -lscreen -lEGL -lGLESv1_CM -lm” to satisfy some of the system dependencies for the BlackBerry SDL port.

I was very surprised how much worked out of the box. webOS implements the accelerometer as an SDL joystick. Instead, BlackBerry has a system API to poll the accelerometer. I was able to easily implement the call.

Literally, the only other thing we needed was to adjust some directory paths. For the webOS target, we used Times, Arial and Courier as default fonts. Instead of being located under “/usr/share/fonts”, these were found on the PlayBook under “/usr/fonts/font_repository/monotype”. We are able to access the files inside our application package using “app/native”, the application storage directory at “data”, and the user documents directory at “shared/documents”

The package format and tools for bundling and installing applications is different than other platforms, but not very complex. NME includes command-line tools to build and install for each platform. The BlackBerry specific code is located here, and our template bar-descriptor.xml file is found here.

You can also find more information about packaging on the BlackBerry Developer site.

If you have any questions, I would be glad to help.

  • Amazing news! And congratulations again for sowing how great NME is 🙂

  • Fernando

    thanks for your work, this is very cool. Black Berry phones are not supported yet right? If you call it “BlackBerry target” and nothing else, is a bit confusing, maybe it should be called “BlackBerry Playbook target”

  • I am sorry this is confusing.

    NME applications for BlackBerry will run on the Tablet OS for the PlayBook, as well as BlackBerry 10. If there is interest, we can support BlackBerry 7 (or older) devices using the HTML5 target.

  • fanplayr

    Wow, awesome work mate. You are an unstoppable powerhouse ! Now, you just have to get Blackberry to pay haxe foundation for helping them not die as quickly …