Search code examples
linkerautoconfautomakelibtool

Using libtool and autoconf


I am working on a system where libraries are installed with libtool (I just discovered libtool) and it seems to be a powerful tool like autotools.

My problem is that I am not able to link my programs using autoconf and automake. After some googling and stackoverflowing, I found how to link my program manually with libtool.

My question is, how to use libtool with autoconf? What are the commands to add in configure.ac and/or Makefile.am? I also found the lazy solution of copying the dependency from the .la file and put it in configure.ac, but I think it is the wrong solution.

I usually work on a system where I have the root permissions, so I am usually lazy and always install many things at system level, and everything always run smoothly until today where I am on a system where I do not have root privileges.


Solution

  • After more googling, I found the solution.

    1) Add the macro LT_INIT to configure.ac

    LT_INIT(static)
    

    There are many other options, see http://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html#LT_005fINIT

    2) Add the variable progname_LDADD to Makefile.am

    progname_LDADD = library_name.la
    

    where progname is defined in

    bin_PROGRAM = progname
    

    There are certainly things that I am missing, but it is working for now. Any suggestion is welcome.