SDK Tools Guides


Building the MoSync SDK from Source on Linux

This guide explains how to build the MoSync SDK from source on Linux. It shows you how to set up your build environment and how to build GCC, Pipe-Tool, and the MoRE Emulator.

Please remember that support for Linux is limited and the build system was made for Windows. At the moment, it is only possible to build the MoRE Emulator on Linux, and to run some example programs in the Emulator. It is not possible to build the entire MoSync package (with its IDE) on Linux.

The distributions that we ourselves run at MoSync AB are Ubuntu 8.10/9.04/9.10 and Xubuntu 9.10. This description may work with those distributions. If you're using any other distribution, you may need to adapt these instructions.


There are a few prerequisites to building the MoSync SDK. In Ubuntu, they can be installed by:

sudo apt-get install gcc g++ bison flex ruby rake subversion rpm libgtk2.0-dev libexpat1-dev
sudo apt-get install libbluetooth3-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev
sudo apt-get install libfreeimage-dev gperf

Note that, since the MoSync SDK is continuously evolving, there may be additional dependencies.

Setting up your Build Environment

The first step is to set up a directory where the compiled binaries, libraries and SDK header files will reside. From now on we will refer to this directory as the installation directory. The installation directory, which resides wherever you want, should contain the following directory structure:


The /include and /lib directories will be created automatically during compilation, but the other directories should be created manually because we need to compile GCC before the MoSync SDK can be compiled.

Once you have created the directory structure, the environment variable MOSYNCDIR should point to the installation directory. If you use bash then this is accomplished by adding the following line to your .bashrc:

export MOSYNCDIR=<installation-directory>

or in csh by adding the following line to .cshrc:

setenv MOSYNCDIR  <installation-directory>

When the lines have been added to your .bashrc or .cshrc the shell must be restarted, you can accomplish this by closing the terminal window and opening it again.

Building GCC

MoSync uses its own GCC backend that generates source code for the MoSync virtual machine. In order to build the MoSync GCC we start by downloading the source code from Google Code, the source code can be placed wherever you want, in this example we are using a directory called gcc_trunk. To download the code run svn:

git clone git:// gcc_trunk

Now go into gcc_trunk and build the compiler, the compilation will fail when trying to compile libgcc since we do not use the standard linker. But the compiler will already have been built and will be placed in gcc_trunk/build/gcc/gcc/.

We build the compiler by performing the following steps:

cd gcc_trunk
cd build/gcc

Remember that the compilation will fail when trying to build libgcc, on my Ubuntu machine the error output begins with:

libgcc2.s: Assembler messages:
libgcc2.s:1: Error: unknown pseudo-op: `.model'
libgcc2.s:2: Error: unknown pseudo-op: `.code'

In order for the build scripts to find MoSync GCC it has to be moved to the installation directory:

cp gcc/xgcc gcc/cpp $MOSYNCDIR/bin
cp gcc/cc1 gcc/cc1plus $MOSYNCDIR/libexec/gcc/mapip/3.4.6/

Building Pipe-Tool and the Emulator

The source code for the MoSync SDK also resides on Google Code and is downloaded by:

git clone git:// mosync_trunk

MoSync uses its own build system coined 'work'. The build system consists of a set of Ruby files that compiles the MoSync SDK. In each directory that contains source files there is a file called workfile.rb, which instructs the build system how compile the source files. To build the fundamental tools of the MoSync SDK, move to the root of mosync_trunk and invoke:

./workfile.rb CONFIG="debug"

The above command builds the tools and libraries in debug mode but you should also build everything in release mode:

./workfile.rb CONFIG=""

You will then have to copy the font used in the emulator to the bin directory, stand in the root of mosync_trunk and invoke:

cp tools/ReleasePackageBuild/build_package_tools/mosync_bin/unifont-5.1.20080907.ttf $MOSYNCDIR/bin/

When this script is finished make sure that $MOSYNCDIR/bin contains cc1cc1plusxgccpipe-tool and moemu. You may then try the MAUIex example by performing:

cd examples/MAUI/MAUIex/
./workfile.rb CONFIG=""
cd build/pipe_release/
$MOSYNCDIR/bin/moemu -program program -resource ../resources

MoSync SDK 3.3
Copyright © 2013 MoSync AB