[SOLVED]Using Root with an automake/autoconf/libtool project

Hey Rooters,

I am working on a project that uses automake/autoconf/libtool, and in one of the libraries I want to use Root features. Although there is an explanation on this topic in ‘man root-config’, I am having problems getting it to work.

Here is the basic setup I used for testing:

I have copied root.m4 to acinclude.m4 in my top directory (where configure.ac is located) and added “ROOT_PATH” to configure.ac.
My /etc/ld.so.conf contains /usr/lib/root, which is the directory containing the Root libs.

The directory containing the library (“Tools”) contains the following:

Makefile.am as described in ‘man root-config’

lib_LTLIBRARIES       = libTools.la

noinst_HEADERS        = Tool.H
libTools_la_SOURCES   = Tool.C
libTools_la_LDFLAGS   = -R @ROOTLIBDIR@
libTools_la_LIBADD    = -lCore -lCint @ROOTAUXLIBS@
# I had to replace "libTools_la_LDADD" with "libTools_la_LIBADD" because automake complained about this (maybe a mistake in 'man root-config'?)



#include "TROOT.h"    // #include "root/TROOT.h"
#include "TCanvas.h"  // #include "root/TCanvas.h"
#include "TH2F.h"     // #include "root/TH2F.h"

void DrawHist()
  TROOT root("GetData","Get Data") ;
  TCanvas mycanvas("name","title") ;
  TH2F myhist("myhistname","my hists title",50,0,50,50,0,50);
  myhist.Draw() ;

The problem: On compiling (libtoolize, aclocal, automake, autoconf, configure, make install), this either gives me

###When I use #include "TROOT.h" etc. as in Tool.C above:###
../Tools/Tool.C:1:19: TROOT.h: No such file or directory
../Tools/Tool.C:2:21: TCanvas.h: No such file or directory
../Tools/Tool.C:3:18: TH2F.h: No such file or directory


###When I use #include "root/TROOT.h" etc. as in Tool.C above:###
g++ -g -O2 -o FOO -rdynamic Main.o  -L/home/frank/hep/foo/../lib /home/frank/hep/foo/../lib/libTools.so -L/usr/lib/root -lCore -lCint /usr/lib/libstdc++.so -L/usr/lib/gcc/i686-pc-linux-gnu/../.. -lf2c -lm -ldl -Wl,--rpath-Wl,/home/frank/hep/foo/../lib -Wl,--rpath -Wl,/home/frank/hep/foo/../lib
Main.o(.text+0x5a): In function `DrawHist()':
../Tools/Tool.C:10: undefined reference to `TCanvas::TCanvas(char const*, char const*, int)'
Main.o(.text+0x62):../Tools/Tool.C:10: undefined reference to `TCanvas::~TCanvas()'
collect2: ld returned 1 exit status
make[1]: *** [FOO] Error 1

What did I miss? Thanks a lot, Frank

I have found my mistake.
I didn’t put any “Root-stuff” into the Makefile.am of my run-directory (containing the Main.C). Now everything works as I wanted. :slight_smile: