How to Compile Gammu on Red Hat Linux

A fair warning: this only applies to Red Hat 5.11. Later versions of Red Hat Linux may have a lot less problems.

Now, you may ask, what the heck is gammu? It is actually a group of utilities to manage a GSM phone from the command line. It allows you (among other things) to send SMS straight to your own personal phone, as long as you have a GSM phone connected to your machine, either through USB or some other means of connection. Pretty useful, since your monitoring server can inform you, through gammu, of the issues that may pop up on your servers.

Another fair warning: gammu requires a fairly recent version of cmake to compile. We are going to detail all that in the rest of this page.

1. Compile the latest version of cmake.

Red Hat Enterprise Linux 5.11 comes with a rather old version of cmake, and gammu is going to complain this is not good enough.

On the other hand, it is very easy to compile the latest cmake, simply get the latest version, un-tar it, cd to the directory and enter:

# ./bootstrap
# make
# make install

The latest version of cmake should now be installed in /usr/local/bin/cmake. Here is a quick comparison of the two versions (stock Red Hat version first):

# /usr/bin/cmake --version
cmake version 2.6-patch 4

# /usr/local/bin/cmake --version
cmake version 3.3.1

Much better!

2. Compile and install gammu.

Now, compiling gammu is not that hard, but it requires, on Red Hat 5.11, a specific option that was given to me by the gammu programmer himself... A very nice person if I ever saw one, and very responsive when you file a Github issue!

If you do not use this compilation option, the entire process will fail with the following error:

[ 18%] Building C object libgammu/CMakeFiles/libGammu.dir/misc/coding/md5-glib.c.o
/root/gammu_tmp/gammu/gammu-1.36.4/libgammu/misc/coding/md5-glib.c: In function ‘CalculateMD5’:
/root/gammu_tmp/gammu/gammu-1.36.4/libgammu/misc/coding/md5-glib.c:11: error: implicit declaration of function ‘g_compute_checksum_for_data’
/root/gammu_tmp/gammu/gammu-1.36.4/libgammu/misc/coding/md5-glib.c:11: error: ‘G_CHECKSUM_MD5’ undeclared (first use in this function)
/root/gammu_tmp/gammu/gammu-1.36.4/libgammu/misc/coding/md5-glib.c:11: error: (Each undeclared identifier is reported only once
/root/gammu_tmp/gammu/gammu-1.36.4/libgammu/misc/coding/md5-glib.c:11: error: for each function it appears in.)
/root/gammu_tmp/gammu/gammu-1.36.4/libgammu/misc/coding/md5-glib.c:11: warning: assignment makes pointer from integer without a cast
make[3]: *** [libgammu/CMakeFiles/libGammu.dir/misc/coding/md5-glib.c.o] Error 1
make[3]: Leaving directory `/root/gammu_tmp/gammu/gammu-1.36.4/build-configure'
make[2]: *** [libgammu/CMakeFiles/libGammu.dir/all] Error 2
make[2]: Leaving directory `/root/gammu_tmp/gammu/gammu-1.36.4/build-configure'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/root/gammu_tmp/gammu/gammu-1.36.4/build-configure'
make: *** [all] Error 2

To make a long story short, this error comes from the version of glib2 which is installed by default on Red Hat 5.11. However, it is possible to bypass glib2completely and compile gammu successfully.

Here is the ''magic'':

# cmake -DWITH_Glib=OFF  -DCMAKE_INSTALL_PREFIX=/usr/local/gammu-1.36.4
# make 
# make install

And... That's all there is to it!

Many thanks to Michal Čihař for his help and for maintaining gammu!

See Also: