Re: Libtool problems

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Fri May 31 2002 - 05:11:37 EDT

  • Next message: Peter H. L. Christiansen: "Re: pc_app/dst/* (fwd)"

    Hi Jens, et al, 
    
    On Wed, 29 May 2002 14:05:19 +0200
    Jens Ivar Jordre <jensivar.jordre@fi.uib.no> wrote
    concerning "Libtool problems":
    > Howdy fellow brahmsers.
    > 
    > Today I checked out the latest version of BRAT and unfortunately got 
    > stuck in compilation. More specifically it is libtool that complains 
    > about not using absolute run-paths. My terminal output is the following:
    > 
    > .....
    > Making all in data
    > gmake[1]: Entering directory `/home/jens/brahms/brat/data'
    > Making all in abc
    > gmake[2]: Entering directory `/home/jens/brahms/brat/data/abc'
    > /bin/sh ../../libtool --mode=link c++  -g -O2  -o libBratDataAbc.la 
    > -rpath /usr/local/lib -version-info 2:3:0 -L/usr/local/lib 
    >   -rdynamic -R  -R  BrClonesArray.lo BrCreationID.lo BrVersion.lo 
    > BrDataObject.lo BrDataTable.lo BrEvent.lo BrEventHeader.lo 
    > BrEventNode.lo BrEventList.lo BrFileTag.lo data_abc_Cint.lo -lCore 
    > -lCint -lm -ldl -lpthread -rdynamic
    > libtool: link: only absolute run-paths are allowed
    
    <snip/>
    
    > Any suggestions for remedies?
    
    I'm sorry, it's my fault.  I was updating some of the Autotool stuff
    and forgot to checkin in change - a very hectic Tuesday I'm afraid.
    The problem was, that `ROOTRPATH' wasn't set an exported (with
    `AC_SUBST') from `BRAT_ROOT' in `acinclude.m4'.  It's fixed now.
    Sorry about that.  
    
    Let me try to explain what happened, so that ye'all (quoting Kris)
    know what's going on: 
    
    In `configure.in' the M4 macro `BRAT_ROOT' is called.  This macro is
    defined in `acinclude.m4'.   When you do `aclocal' the program looks
    for all macros needed by `configure.in' which is not in `autoconf's
    normal search path [1], and put's them in the file `aclocal.m4'.  
    
    The next step, running `automake -a' does some checks on the macros
    used, but does not check that all variables are defined and so on.  
    
    Then, when you run `autoconf' all the macros used in `configure.in' is
    turned into shell (`sh') commands and written to `configure'.  When
    you run `configure' all that shell stuff is executed, which involves
    substituting variables into the generated `Makefile's.  
    
    Take a look in `acinclude.m4', and find the macro `BRAT_ROOT'.  It
    contains a line that reads 
    
      AC_PATH_PROG(ROOTEXEC, root, no, $rootbin)
    
    This will check for the program `root' in the path `$rootbin'.  If
    it's found, the _substitution_ variable `ROOTEXEC' is set to the full
    path of the program; if not it's set to `no'.  
    
    A substitution variable is one that `configure' will substitute into
    the `Makefile's where `@<variable>@' is present.  So in the above
    case, supposing `root' is in '/usr/bin' the variable `ROOTEXEC' will
    have the value `/usr/bin/root', and if any `Makefile.am' (or rather
    `Makefile.in')  contains the string `@ROOTEXEC@' then `configure' will
    substitue in the value `/usr/bin/root'.  
    
    Now take a look futher down in the same macro.  There you'll see the
    lines 
    
      ROOTLIBDIR=`$ROOTCONF --libdir`
      ...
      ROOTRPATH=$ROOTLIBDIR
      ...
      AC_SUBST(ROOTRPATH)
    
    This is really straight forward. We set the variable `ROOTRPATH' and
    then declare it to be a substitution variable. 
    
    Now for the `libtool' stuff.  Libtool can help you and your users out
    a great deal, by automatically link in libraries that are needed by
    you libraries, as well as setting the run time load path for the
    dynamic linker.  Take a look in `brat/data/abc/Makefile.am' where
    you'll find the lines 
    
      lib_LTLIBRARIES            = libBratDataAbc.la
      libBratDataAbc_la_LDFLAGS   = $(SO_VERSION) $(ROOTLDFLAGS) -R $(ROOTRPATH)
      libBratDataAbc_la_LIBADD  = -lCore -lCint $(ROOTAUXLIBS)
      libBratDataAbc_la_SOURCES =      \
      ...
    
    The first line says that `libBratDataAbc.la' should be build by
    `libtool' and installed in `@libdir@' (per default `${HOME}/lib'). 
    
    In the next line, we first set the version number to put into the
    soname of the library.  I'm not going to explain sonames - please
    refer to your linkers documentation.  Then we add any flags that the
    linker might need to make the library, and finally, we tell `libtool'
    to put `$(ROOTRPATH)' - a substitution variable - into the run time
    link path for this library.  
    
    The third line says, that when ever we load or link against this
    library, the dynamic linker should also load in `libCint', `libCore',
    and any libraries in `$(ROOTAUXLIBS)'.  In that way, you can simply
    load the library directly and you needn't worry about it's
    dependencies.  Also, if you want to link a program/library against
    this library, you can simply do 
    
      g++ foo.cc -o foo -L@libdir@ -lBratDataAbc 
    
    and `libCint', `libCore', and any libraries in `$(ROOTAUXLIBS)' will
    automatically be linked in too.  That's kinda nifty isn't it? 
    
    Well, now for the problem.  Obviously, the `-R' flag to `libtool'
    needs an argument.  However, I forgot to put in the lines 
    
      ROOTRPATH=$ROOTLIBDIR
      ...
      AC_SUBST(ROOTRPATH)
    
    in the version i checked in, and so the `make' variable `$(ROOTRPATH)'
    was empty, and hence your predicament.  
    
    Now you all know, and should be able in the future to fix something
    like this yourself :-)  Please also refer to the references in `The
    Guide'. 
    
    Yours, 
    
     ____ |  Christian Holm Christensen 
      |_| |	 -------------------------------------------------------------
        | |	 Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
         _|	          DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
        _|	          Denmark                    Office: (+45) 353  25 305
     ____|	 Email:   cholm@nbi.dk               Web:    www.nbi.dk/~cholm
     | |
    
    
    [1] usually `/usr/share/autoconf', however
        `/afs/rhic/opt/brahms/pro/share/autoconf' on the RCAS farm. 
    



    This archive was generated by hypermail 2b30 : Fri May 31 2002 - 05:12:38 EDT