Archive for the 'Software engineering' Category

Published by Niels on 17 Jan 2014

Autotools Cookbook Notes, Part 3

In the previous instalment, Autotools were used to create a separate library from our source code. This time I will show how to add unit tests.

Unit testing is a very important tool for every software engineer and fortunately the Autotools provide us with an easy way to create and use unit tests. After creating the tests running them is as easy as running the following command on the command line:

make check

I will continue where I left of with the Autotools setup for libraries to show how to incorporate unit tests in your project based on the CppUnit. Why not one of the more recent C++ unit test environments such as the Boost Test Library or CxxTest? Simply because I am more experienced using CppUnit and know how to set up Autotools with it. In later instalments I will add setups for other testing frameworks but these setups will probably deviate not too much from the setup using CppUnit.

It is of course assumed that the CppUnit test framework is already installed on your machine. If not then the internet provides sufficient information on how to do so. Continue Reading »

Published by Niels on 06 Feb 2011

Remove Build Dependencies after ‘apt-get build-dep’

I recently started to have a look at the LibreOffice code to see if I could contribute to it. On their developers web page there is a nice tutorial on how to install all the build dependencies for it using Debian based Linux distributions like Ubuntu. If you want to get rid of all these dependencies after a while, for example because you are no longer interested or you need the disk space, it is very hard to delete them. Fortunately I found a working solution here.
To make things a bit easier I built a script to for command line use that can be downloaded here:

sudo aptitude markauto $(apt-cache showsrc "$1" \
    | grep Build-Depends \
    | perl -p -e 's/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g')

It can be invoked as follows (assuming it is in your PATH):


I want to emphasize that I did not invent this method, the credits should have to go to the persons that posted the solution on Launchpad.

Published by Niels on 26 Dec 2010

Autotools Cookbook Notes, Part 2

In the previous instalment a skeleton Autotools project was created. In this instalment the usage of libraries for the application code will be added. I like putting my application data into libraries as it makes it more convenient to reuse the code, e.g. when doing unit testing (which will be shown in a later instalment).

In this instalment a skeleton setup for handling libraries using Libtool will be presented. At the end the methods to link against the static or dynamic libraries will be shown. The created library will be a very trivial one but the created skeleton should be enough to expand on this.
Continue Reading »

Published by Niels on 25 Dec 2010

Autotools Cookbook Notes, Part 1

For most software projects that go past the trivial state a build environment can assist in helping with finding dependencies, providing alternatives, documentation creation, unit testing, etc. One of the most flexible environments are provided by the GNU Autotools, but setting up a new Autotools project can be a bit cumbersome. It always seem to give me the feeling that I have to rediscover everything about the GNU Autotools and to avoid making the same mistakes over and over again I kept a lot of notes. The disadvantage of personal notes are of course:

  • They get disorganized
  • They are hard to keep up-to-date
  • They are not always available
  • It is difficult to transfer the knowledge contained in them to another person

So therefore I decided to do what I always do to solve these issues: I publish the knowledge on a subject that I obtained so far on my homepage. It will be series of instalments, each building on the knowledge from the previous instalments. In this first instalment a trivial ‘Hello, World!’ project will be created. Later instalments will provide information on:

But more subjects might be added in the future. It is also most likely that new insights will be added to already published parts and I will try to indicate the new additions as good as possible.

Since I consider these my personal notes they are not a replacement for the full GNU Autotools documentation and other resources. For more in-depth information the following on- and off-line resources are recommended:

Although I consider these my notes, complete with rough-edges and warts and all, and by no means a complete tutorial on the subject I do still appreciate any remarks or comments. Nowhere will a setup guide for the used tools be given. These differ to much from system to system and with the use of Google resources with better information than I can provide should be available.

Continue Reading »

Published by Niels on 02 Apr 2010

Error: Cannot modify header information…

If PHP ever gives you the following error (I just encountered it while developing with the Yii Framework):

Cannot modify header information - headers already sent by

Then you probably injected some whitespace somewhere in your output. The easiest way to avoid that is by not using the PHP closing tag ‘?>‘ at the end of PHP source files. Some people are against that but if I look into the sources for Yii and read the Zend Framework Programmer’s Reference Guide then it is obviously a well established method of avoiding the mentioned error.