{"id":201,"date":"2012-04-01T23:25:19","date_gmt":"2012-04-01T22:25:19","guid":{"rendered":"http:\/\/paguilar.org\/?p=201"},"modified":"2012-04-01T23:25:19","modified_gmt":"2012-04-01T22:25:19","slug":"cross-compiling-gnokki","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=201","title":{"rendered":"Cross-compiling gnokki"},"content":{"rendered":"<p><strong>[Updated: 15\/03\/2013]<\/strong><\/p>\n<p>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:<\/p>\n<p><strong>gsm-utils<\/strong><br \/>\nPackage: <a href=\"http:\/\/packages.debian.org\/squeeze\/gsm-utils\"> gsmlib_1.10.orig.tar.gz <\/a><br \/>\nThis project is quite old and unmaintained. If you compile it with a recent gcc (I was using 4.3.x), you&#8217;ll need to apply this <a href=\"http:\/\/ftp.de.debian.org\/debian\/pool\/main\/g\/gsmlib\/gsmlib_1.10-13.diff.gz\">patch<\/a> 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.<\/p>\n<p><strong>gammu<\/strong><br \/>\nPackage: <a href=\"http:\/\/sourceforge.net\/projects\/gammu\/files\/gammu\/1.31.0\/gammu-1.31.0.tar.bz2\">gammu-1.31.0.tar.bz2<\/a><br \/>\nGammu is a fork of gnokii (the third option), it&#8217;s well documented, it&#8217;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.<br \/>\nSince I can only use SQLite3, I don&#8217;t need the portability to other databases making the use of libdbi redundant.<\/p>\n<p><strong>gnokii<\/strong><br \/>\nPackage: <a href=\"http:\/\/www.gnokii.org\/download\/gnokii\/0.6.x\/gnokii-0.6.31.tar.bz2\">gnokii-0.6.31.tar.bz2<\/a><br \/>\nGnokii 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.<br \/>\ngnokii&#8217;s SMS daemon, <em>smsd<\/em>, is quite light, making it suitable for small ARM processors like the one I have.<br \/>\nLatest versions support SQLite3 so I could even put the two tables that  smsd uses for sending and receiving SMS inside my database.<\/p>\n<p>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.<\/p>\n<p>I decided to use gnokii and document its building procedure since the cross-compilation is not straight forward. <\/p>\n<p>This is the procedure I followed:<\/p>\n<p>Set the following environment variables that will make our life easier:<\/p>\n<pre lang=\"bash\">\n$ export BUILD=i386-linux\n$ export HOST=arm-linux\n$ export PROJECT_PATH=\/home\/projects\/rootfs\n<\/pre>\n<p>Configure:<\/p>\n<pre lang=\"bash\">\nGLIB_CFLAGS=\"-I$PROJECT_PATH\/usr\/include\/glib-2.0 -I$PROJECT_PATH\/usr\/lib\/glib-2.0\/include\" \nGLIB_LIBS=\"-L$PROJECT_PATH\/usr\/lib\" \nSQLITE3_CFLAGS=\"-I$PROJECT_PATH\/usr\/include\" \nSQLITE3_LIBS=\"-L$PROJECT_PATH\/usr\/lib\" \n.\/configure \n--build=$BUILD \n--host=$HOST \n--without-x \n--without-bluetooth \n--without-libical \n--disable-libusb \n--disable-phonet \n--enable-sqlite \n--disable-xdebug\n<\/pre>\n<p>Before building, edit the following Makefiles:<\/p>\n<ol>\n<li>common\/phones\/Makefile<\/li>\n<li>common\/links\/Makefile<\/li>\n<li>common\/devices\/Makefile<\/li>\n<li>common\/data\/Makefile<\/li>\n<li>gnokii\/Makefile<\/li>\n<li>common\/Makefile<\/li>\n<li>utils\/Makefile<\/li>\n<li>gnokiid\/Makefile<\/li>\n<\/ol>\n<p>Unset the variable <em>LIBS<\/em>:<\/p>\n<pre lang=\"bash\">\nLIBS =\n<\/pre>\n<p>Edit the files <em>gnokii\/Makefile<\/em> and <em>gnokiid\/Makefile<\/em>:<br \/>\nSet the variable <em>LIBS<\/em> to the following value:<\/p>\n<pre lang=\"bash\">\nLIBS =  -L\/home\/projects\/rootfs\/usr\/lib -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0\n<\/pre>\n<p>Edit the file <em>smsd\/Makefile<\/em>:<br \/>\nSet the variable <em>GLIB_LIBS<\/em> to the following value:<\/p>\n<pre lang=\"bash\">\nGLIB_LIBS = -L\/home\/projects\/rootfs\/usr\/lib -lsqlite3\n<\/pre>\n<p>Set the variable <em>CFLAGS<\/em> to the following value:<\/p>\n<pre lang=\"bash\">\nCFLAGS = -g -O2 -Wall -Wno-pointer-sign -fvisibility=hidden -fno-strict-aliasing -I\/home\/projects\/rootfs\/usr\/include\n<\/pre>\n<p>Now you can build and install in <em>\/home\/projects\/rootfs\/usr\/local<\/em>:<\/p>\n<pre lang=\"bash\">\nmake\nmake DESTDIR=$PROJECT_PATH\/usr\/local install\n<\/pre>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[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\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=201\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,11],"tags":[],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-compiling","category-hspa"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":0,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}