when I lauch make it compile all files with root directives , but not the final linking:
g++ -g -O2 -o calibrazione main.o integrale.o rdTXOclass_2.o colonna.o torre.o
and it says stuff like this:
undefined reference to `TGraphErrors::TGraphErrors(int, float const*, float const*, float const*, float const*)’
INCLUDES = $(shell root-config --cflags) $(shell root-config --libs) $(shell root-config --glibs)
is wrong - you’re mixing compiler and linker flags, and INCLUDES should only contain the compiler’s include search path directives. You’ll have to add the root-config --glibs to the autotools library statement.
I’m sure you’ll spend far more time on this than just running “.L includes_all_sources.C+”, which loads all your code (via a file which #includes all your sources) as a shared library into ROOT, so you can execute your compiled code. But it’s of course up to you
INCLUDES = $(shell root-config --cflags) $(shell root-config --libs) $(shell root-config --glibs)
is wrong - you’re mixing compiler and linker flags, and INCLUDES should only contain the compiler’s include search path directives. You’ll have to add the root-config --glibs to the autotools library statement.
I’m sure you’ll spend far more time on this than just running “.L includes_all_sources.C+”, which loads all your code (via a file which #includes all your sources) as a shared library into ROOT, so you can execute your compiled code. But it’s of course up to you
Cheers, Axel.[/quote]
Thanks, but I prefer using autotools and gcc and not CINT
I suppose you have at least a configure.ac and a Makefile.am file. The configure.ac have to contain a call to search, at configure script level, the ROOT libraries.
With ROOT are ditribuited several scripts and in particular the script root.m4, in this script exist the macro ROOT_PATH, in the script there are same examples, basically you can only add the row
[quote=“volpig”]
To have a common base you can attach your cnfigure.ac and the Makefile.am[/quote]
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT(a, 0.1, asd)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
# Checks for library functions.
AC_CHECK_FUNCS([strstr])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
I think you are near to the solution, try with this changes
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT(a, 0.1, asd)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
ROOT_PATH
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
# Checks for library functions.
AC_CHECK_FUNCS([strstr])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Is possible that root.m4 is not in a directory read by autoconf; try to run autoconf using this command:
$ autoconf -I $ROOTSYS/build/misc
[/quote]
it says:
Can't locate object method "path" via package "Request" at /usr/share/autoconf/Autom4te/C4che.pm line 69, <GEN1> line 217.
[/quote]
I don’t know this error message.
I can send you this exmple:
ROOT_PATH(,[
AC_DEFINE([HAVE_ROOT],,[Root library])
AC_CHECK_LIB([dl],[dlopen],[],AC_MSG_ERROR([Root libraries not linking properly]))
],AC_MSG_RESULT([Some parts of software will be not compiled]))
AM_CONDITIONAL(EXISTROOT,test x$no_root = "x")
this test also is ROOT library exists, I copied the root.m4 file in a subdirectory of the project, with a random name m4/ , so I call aclocal in the main directory of the project with the syntax:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(alone, 0.1)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([alone.cpp])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
ROOT_PATH
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
# Checks for library functions.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
now I don’t have time to search in the documentation but I think that one of this macro or the simple insertion of the @LIBS@ variables can solve your problem.
checking dependency style of gcc... gcc3
checking for ranlib... ranlib
checking for root-config... /bin/root/bin/root-config
checking for root... /bin/root/bin/root
checking for rootcint... /bin/root/bin/rootcint
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
the old alone.cpp is now main.cpp (I’ve correctly changed the name in configure.ac and Makefile.am)
not good! if you have a large program (like ROOT) how can you distribuite it? With a single Makefile for all users? If I have a pc linux, my friend a sparc computer, maybe I want to compile the source optimize with my processor… if I haven’t a optional library…
quite all (I know 2 program that doesn’t use gnu autools, one is geant4, in fact from my point of view it is hard to install) gnu programs are distribuite with configure/make installation method automatically created with autools.[/quote]