Skip to main content

Autohell and CMake

Time for another software related post.

People familiar with the GNU/Unix system would know that the standard way to install about any GNU software from code is to run the following commands

  • configure
  • make
  • sudo make install

These commands are from the GNU autotools environment. Knowing the GNU environment, these tools are what I used to compile most of the (relatively small) pieces of code I wrote.

Until I discovered CMake.

CMake, or Cross-platform Make is a tool that serves the same functionality as the GNU autotools (hereafter referred to as autohell). As the name suggests, CMake can be used to compile software across multiple platforms.

Why am I encouraging CMake over autohell? Well, firstly, it’s not autohell! The GNU autotools are extremely useful when compiling on Linux. That’s what they are designed for. Cross compilation is extremely easy with the --host= flag. Unfortunately, when it comes to using them on Windows, the system just becomes a pain in the neck.

People who have tried to compile a GNU package on Windows would know what I’m speaking about. You type in configure, wait for about half an hour while the script does its job in the MSYS terminal, then enter make -j4 (to speed up the process), wait for an hour while libtool compiles the bloody code, then make install (finally!).

The reason why the process is so painfully slow is that autotools, at their heart are just shell scripts. This means that while compiling for Windows, in an MSYS terminal, the shell script is parsed by sh.exe, which is a slow emulator of the Unix shell. Further, when the configure script has done its job, the Makefile takes over, which relegates all compile operations to libtool, which is another bloody shell script. More sh.exe calls! The result? A painfully slow compile and installation process. Contrast that with CMake. Now, CMake exists on all platforms. It’s simple and elegant, and allows a choice of compilers, right from MSYS Makefiles, to CodeBlocks MinGW projects, to Visual Studio project files.

To prove my point, I’d just recommend that you checkout a simple project (Library management system, my 12th grade project) in my GitHub repository, which can be compiled using autohell as well as CMake. The CMake step takes a second, while autohell takes over a minute (on Windows). Moreover, the CMakeLists.txt file is short and sweet, and was written in under a minute. By contrast, I took ages to write autohell files, what with configure.ac, Makefile.am and stuff. I switched from autohell to CMake immediately.

Comments

  1. this is informative... though most of such posts of urs just flow over my head, this one I did understand (~20%) as to what you are trying to say. partly bcoz I have to use linux and Windows and install codes on them... but nevertheless, you've clearly tried ur best! :-D

    ReplyDelete
    Replies
    1. Just try compiling a project (on a non-Unix system) with CMake, and then with auto-tools. You'll get what I mean.

      Delete

Post a Comment

Popular posts from this blog

On Harry Potter and why I dislike the series

There could not be a better time for this post. There could not have been a worse time for this post. Now that the penultimate movie of the series is out, and my facebook wall filled with people who loved the movie. But this is something I really wanted to say, and I shall say it anyway. Harry Potter is pathetic literature. Now, you must be wondering why I say that. There are many reasons. Firstly, the storyline itself is flawed. When a writer sits down to write anything, he/she must set up some essential rules about what is happening. These rules must remain constant irrespective of how many times he/she changes his/her mind. This is so that the readers are allowed to have some sensibility in what they are reading. In the fourth book, Rowling goes ahead and kills Cedric. Then, at the end of the book, the horseless carriages are there again. Nothing special. We all knew that they are horseless. But then comes the fifth book, and BAM, the horses are actually winged beasts that only thos...

On the Dvorak Simplified Keyboard

This is a post that I have been meaning to write from quite some time. Long hours spent typing code on my computer left my hands fatigued, and left me with a lot of pain in my wrists and fingers. That is when I decided to use the Dvorak. But I have got the same bad habit as Dr. Watson, to tell a story backwards. Of course, you must be wondering what the Dvorak is. The story of keyboards starts with the invention of the typewriter. Christopher Sholes, the inventor of the typewriter, tried with a two row piano style keyboard. But then, he got into many difficulties with the design. Then he finally settled for a four row design. This was similar to the QWERTY layout that most computers and typewriters today possess. The engineers at Remington, to whom Sholes had presented his design modified the layout a little further, and then the QWERTY was born. As typewriters became popular, people got used to the layout, and started practising touch typing, i.e. typing without looking at the keys...

Elements of a Story: The Whispers

I'm compelled to begin each post with a meta. That way, my blog posts seem less like essays or dissertations, and more like diary entries, or web logs. So here goes... I started this blog a little over a year ago. The main purpose of this blog was to experiment with styles of writing, and find an effective outlet for all the subjects I wish to rant about; saving my classmates the agony of having to listen to them. As I wrote this blog, I've experimented with so many styles, and have received comments claiming that my work is a shameless copy greatly inspired by so-and-so author/work. Fact is that I simply chanced upon that style. I read, so obviously, my work shall reflect the styles of those I admire, but I've worked out so many styles without even knowing that they exist, only to be informed of them later. Recently, I've been struck with the seeming absence of whispers as an element of a story. The more I've thought of the subject, the more I've been convince...