Setting up a Pebble simulator in 64 bit Linux (Mint/Ubuntu)

One reason I bought a Pebble watch was to develop apps for it, so when I put my online order I didn’t want to wait two or three weeks for my watch to arrive before I could start to write code. So I looked for a Pebble simulator online and I found one, PebbleLocalSim. Unfortunately, there were some hurdles to overcome before the Hello World app would run on my machine (Linux Mint 17, 64 bit), and I thought I would share my way to a working simulated Pebble environment.

1. Install the Pebble SDK
Of course, in order to do anything I had to install the Pebble SDK, so I followed the instructions here:

2. Build Hello World
I made sure my build environment worked correctly by building the Hello World app, as explained here, but I skipped the installation part since I had no actual watch:

3. Get the simulator
I got the simulator by downloading the zip-file from here, but a git clone would probably have worked just as well:

4. Setup the simulator for my Hello World app
The readme file of the simulator said to copy some files into the installed Pebble SDK and since no files would be overwritten I went ahead and did just that. I copied all files and directories from the zipfile path:
to the Pebble SDK path:

The readme file also asked me to install some files, namely:
sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev
I did this but soon trouble would show its ugly face anyway.

5. Try compiling Hello World for the simulator
I changed directory to my Hello World project and tried to build it as a simulated Pebble app:
cd (project)
… and the compilation failed:

In file included from /usr/include/stdint.h:25:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:9,
                 from ./build/tempLocal/src/,
                 from /home/darius/dev/pebble/PebbleSDK-2.3/bin/../Pebble/include/pebble.h:4,
                 from ./src/hello_world.c:1:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
 #  include <sys/cdefs.h>
compilation terminated.

6. Fixing first problem
Some searching on the Internet made me realize that I needed the 32 bit version of the files above, and since I run 64 bit Linux I didn’t install them just then. So I solved that by installing them correctly this time, like this:
sudo apt-get install libsdl1.2-dev:i386 libsdl-image1.2-dev:i386 libsdl-ttf2.0-dev:i386

7. Try compiling again
Then I compiled again and another compilation error appeared.

./src/hello_world.c: In function ‘pbl_main’:
./src/hello_world.c:60:1: warning: control reaches end of non-void function [-Wreturn-type]
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/ when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

8. Fixing second problem
Another search on the Internet gave me that I needed a 32 bit version of the compiler as well, which I installed like this:
sudo apt-get install gcc-multilib

9. Building the app
Finally I was able to build the app, and I ignored the warning:

./src/hello_world.c: In function ‘pbl_main’:
./src/hello_world.c:60:1: warning: control reaches end of non-void function [-Wreturn-type]

10. Running the app
So, in the end I was able to run the app in the simulator (and I ignored the messages outputted in runtime):
cd (project)

[INFO] Entering main
[ERROR] could not read '' - persist_* will start with fresh data!
[INFO] Got 1 keys from ''
[LOG][DEBUG][./src/hello_world.c:56] Done initializing, pushed window: 0xa075558
[DEBUG] Got app_event_loop
[INFO] Wrote 1 keys to ''


Hello World in Pebble Local Simulator
Hello World in Pebble Local Simulator

And finally I was set up to do some serious Pebble programming.


Leave a Reply