Google Protocol Buffers and BlackBerry 10

A brief HowTo on compiling the protobuf library for use in a BB10 application.

I will be assuming you are using the QNX development environment provided by RIM on GNU/Linux (in my case Ubuntu 12.04) and you have the following packages installed:

  • build-essential
  • protobuf-compiler

Step 1 – Preparation

Activate the QNX environment for the version of the BlackBerry 10 NDK you require.

. ./bbndk-env_10_1_0_1720.sh

Step 2 – Downloading

Download and extract the protocol buffers library from Google Code in my case I downloaded version 2.4.1 to match the version packaged on Ubuntu 12.04.

Step 3 – Compilation

This step requires configuring a make file for each target that you want to build for. Both armle (for device) and x86 (for the simulator), if you do development directly onto a device you can skip the second compile.

Use the supplied configure script to generate a make file (for device/armle):

CXX=${QNX_HOST}/usr/bin/ntoarmv7-c++ LD=${QNX_HOST}/usr/bin/ntoarmv7-ld ./configure --host=armle --disable-protoc --with-protoc=protoc --prefix=/PATH/TO/INSTALL

This command specifies which compiler and linker to use, specifies the host as being armle (thereby enabling cross compilation), disables protoc from being built, specifies that the system protoc should be used to generate any code and finally specifies what install prefix to use. This is where the lib, include files are copied during the install process.

Once the make file is completed start the build and install process:

make
make install

This does not run test cases but this is not possible on the host machine when cross compiling.

Step 4 – Integration

Integration into your project requires that you also link in several additional libraries that are required by protobuf.

Modify your projects .pro file and add the following line (including all dependant libs the protobuf requires):

LIBS += -L/PATH/TO/INSTALL/lib -linput_client -linput_utilities -lstdc++ -lprotobuf

Finally update QNX configuration with the path to the include directory.

Done.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: