#Root version and compilers at the bottom of the post
thanks in advance for any help, I am fairly new to ROOT since we are starting to use it in my university class so forgive me if I did any basic mistake. I tried to troubleshoot as best as I could but couldn’t find a proper answer.
I am trying to compile some code in C++ (main.cpp) which is meant to include the following root headers which I implemented in main in this way:
#include "TH1F.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TGraph.h"
the makefile looks like this: (the relevant parts)
myClasses:=../etc.. #this compiles correctly
LIBS:='root-config --libs'
INCS:='root-config --cflags'
main: main.o ${myClasses}
g++ main.o ${myClasses} ${INCS} ${LIBS} -o main
main.o: main.cpp ../Classes/Posizione.h ../Classes/CampoVettoriale.h
g++ -c main.cpp ${INCS} ${LIBS} -o main.o
My .bashrc file looks like this:
export ROOTSYS=/home/michele/Documents/Informatica/ROOT/root
export PATH=$PATH:$ROOTSYS/bin
export LD_LIBRARY_PATH=$ROOTSYS/lib/:$LD_LIBRARY_PATH
Note: the library paths and the general {INCS} {LIBS} commands work for another exercise in another folder so they must be correct. This exercise I have trouble on just has a more complicated header inclusion and therefore a more “complicated” makefile
Once I try to compile with make I get the following error in the terminal:
g++ -c main.cpp -o main.o 'root-config --cflags' 'root-config --libs'
g++: error: root-config --cflags: No such file or directory
g++: error: root-config --libs: No such file or directory
make: *** [makefile:10: main.o] Error 1
Note: line 10 in makefile is the following:
g++ -c main.cpp -o main.o ${INCS} ${LIBS}
The strange thing is that if I execute in the terminal root-config --cflags or root-config --libs I get a positive outcome with the libraries being listed etc. and as I stated before it works properly in another exercise.
Final Note: Visual studio code does give me a “warning” on the #include in main.cpp but I haven’t changed anything in the installation of root or something related to that
[ROOT has been installed properly in the ROOTSYS path and I have tried also to re-execute source root/bin/thisroot.sh]
ROOT Version: 6.24/06
_Platform:_Ubuntu 21.04
Compiler: g++