Getting setup for the roguelike tutorial on roguebasin

Rapsberry Pi 3 model B + Nim + libtcod setup and configuration



System Configuration

My environment is a fresh Raspbian install on a Raspberry Pi 3 model B.

Nim Source Install

To begin, I wanted to get the latest version of Nim installed — as of this writing, 0.19.0. This version was not found in the Raspbian package repositories, so I needed to build it myself.

The build process requires a bit more memory at a certain point in the process than the Raspberry Pi has, and the default swap size (100MB) was a bit to small. I temporarily upped the swap size by editing /etc/dphys-swapfile, setting the CONF_SWAPSIZE value to 512MB and then restarting the service that manages that swap file – sudo /etc/init.d/dphys-swapfile restart.

The Nim installer script doesn’t support ARM, but that’s no problem — the install can be run manually for the system.

The process is as described on the Nim language website:

$ mkdir -p ~/src/nim/
$ cd ~/src/nim/
$ wget
$ tar xvf nim-0.19.0.tar.xz
$ cd nim-0.19.0
$ sh
$ ./bin/nim c koch
$ ./koch tools

Following that up by adding the bin dir to the PATH:

$ echo PATH=$HOME/src/nim/nim-0.19.0/bin/:$HOME/.nimble/bin/:$PATH >> ~/.profile
$ source ~/.profile

At this point, my system was setup for nim development! I decided to put swap size back to 100MB though, didn’t really want to emphasize the use of swap. Might eventually disable it all together. SD cards are purportedly just not meant to handle that kind of writing for very long.


I also had to do a source install of libtcod, as I could not get a new enough pre-compiled version on the Raspberry Pi with Raspbian.

This was also a fairly straight forward process.

$ sudo apt install git curl build-essential make cmake autoconf automake libtool mercurial libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libsdl2-dev
$ git clone ./libtcod
$ cd libtcod
$ git checkout 1.9.0
$ cd build/autotools
$ autoreconf -i
$ ./configure
$ make
$ sudo make install

The tricky bit was realizing I couldn’t us scons (doesn’t support an arm build process) and had to use the autotools. Then I needed to realize the ./configure command couldn’t be called with their example CFLAGS parameter – so the resulting library might not be as optimized, but it works so far, so… I’m fine with that for now.

Otherwise, when I run a Nim application, I need to specify the installed lib path with LD_LIBRARY_PATH since I’m not statically linking the libraries in my nimble build.


$ LD_LIBRARY_PATH=/usr/local/lib/ ./bin/nim-compiled-executable