Monday, October 13, 2014

Autotools with Libtool in Ten Minutes or Less

I've created another version of the package in the previous post that provides file templates for autotools. This version includes the necessary modifications for invoking libtool.

This example is based on the tutorial to which I linked in that post. Note that I found that one modification is necessary to the instructions given in that tutorial. The "autoreconf -fiv" command throws a warning (which will turn into an error in my example, since I have the "-Werror" option set in "configure.ac") if "AM_PROG_AR" does not show up in "configure.ac". Note also that "AM_PROG_AR" must appear before "LT_INIT".

The build steps are the same as in the previous post: 1. Untar the file; 2. Enter the directory; 3. autoreconf -fiv; 4. configure; 5. make.

Note that the file "hello" that make now produces is a script, rather than an executable. To debug this script, execute "libtool --mode=execute gdb hello". This requires that you build with debugging turned on with the "-g" flag. It's also a good idea to turn off optimizations, which you can do with the "-O0" flag. Turn these on when you run configure by running it like so: "./configure CFLAGS='-O0 -g'.

No comments:

Post a Comment