Cross-compiling gnokki

By | April 1, 2012

[Updated: 15/03/2013]

Recently, I needed a software that sends and recevies Short Message Services (SMS) from a Linux ARM-based embedded device. Obviously, I needed something with a small foot-print and not resource-hungry. I found three FOSS options that could fit my needs:

gsm-utils
Package: gsmlib_1.10.orig.tar.gz
This project is quite old and unmaintained. If you compile it with a recent gcc (I was using 4.3.x), you’ll need to apply this patch provided by Debian. The building procedure is straight-forward, but the results, at least for me, were quite disapointing because the SMS daemon crashed very often.

gammu
Package: gammu-1.31.0.tar.bz2
Gammu is a fork of gnokii (the third option), it’s well documented, it’s robust and more complex, and it has a lot of features making it a bit heavier than gnokii. If your hardware is a PC or a high-end ARM processor I would recommend gammu. It also depends on libdbi that implements a database-independent abstraction layer in C, similar to the DBI/DBD layer in Perl.
Since I can only use SQLite3, I don’t need the portability to other databases making the use of libdbi redundant.

gnokii
Package: gnokii-0.6.31.tar.bz2
Gnokii is a set of tools, similar to gammu that allows to send/receive SMS, read/write to a phonebook and other services. I was only interested in the SMS functionality that seemed to cover quite well.
gnokii’s SMS daemon, smsd, is quite light, making it suitable for small ARM processors like the one I have.
Latest versions support SQLite3 so I could even put the two tables that smsd uses for sending and receiving SMS inside my database.

The documentation is not great, but good enough to get started. The code is quite clear and easy to understand. In fact, I found a memory leak in smsd that I fixed and sent to the mailing list. The patch was applied quite fast showing the active development around this project.

I decided to use gnokii and document its building procedure since the cross-compilation is not straight forward.

This is the procedure I followed:

Set the following environment variables that will make our life easier:

$ export BUILD=i386-linux
$ export HOST=arm-linux
$ export PROJECT_PATH=/home/projects/rootfs

Configure:

GLIB_CFLAGS="-I$PROJECT_PATH/usr/include/glib-2.0 -I$PROJECT_PATH/usr/lib/glib-2.0/include" 
GLIB_LIBS="-L$PROJECT_PATH/usr/lib" 
SQLITE3_CFLAGS="-I$PROJECT_PATH/usr/include" 
SQLITE3_LIBS="-L$PROJECT_PATH/usr/lib" 
./configure 
--build=$BUILD 
--host=$HOST 
--without-x 
--without-bluetooth 
--without-libical 
--disable-libusb 
--disable-phonet 
--enable-sqlite 
--disable-xdebug

Before building, edit the following Makefiles:

  1. common/phones/Makefile
  2. common/links/Makefile
  3. common/devices/Makefile
  4. common/data/Makefile
  5. gnokii/Makefile
  6. common/Makefile
  7. utils/Makefile
  8. gnokiid/Makefile

Unset the variable LIBS:

LIBS =

Edit the files gnokii/Makefile and gnokiid/Makefile:
Set the variable LIBS to the following value:

LIBS =  -L/home/projects/rootfs/usr/lib -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0

Edit the file smsd/Makefile:
Set the variable GLIB_LIBS to the following value:

GLIB_LIBS = -L/home/projects/rootfs/usr/lib -lsqlite3

Set the variable CFLAGS to the following value:

CFLAGS = -g -O2 -Wall -Wno-pointer-sign -fvisibility=hidden -fno-strict-aliasing -I/home/projects/rootfs/usr/include

Now you can build and install in /home/projects/rootfs/usr/local:

make
make DESTDIR=$PROJECT_PATH/usr/local install

Gnokii still has some rough edges that can be fixed/improved, but after a couple of months of intensive use its behaviour has been quite stable.

2 thoughts on “Cross-compiling gnokki

    1. paguilar

      Hi, this is not related to any Duolabs product.
      You can read more info about gnokii here.
      Sorry for the late reply, I was on vacation 🙂

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *