ROOT, #include <*.h> not found

Hello, I am currently taking a Computational physics course and in my school lab computers I can run makefile without any issues.

I have installed ROOT on my ~/ROOT on my personal computer and I have the following in my .bashrc
#Loading Root in /HOME/ROOT/bin/

export PATH=$ROOTSYS/bin:$PATH

#Below is the experimental library path to make the system to work.

#Did not work, 24 Sept 14.

#Loading the Python parts to load and be able to import from Pydocs in HOME

#Allows modules loaded on Pydocs to be imported without hassle

#Setting up PyROOT

#Unsure of the effects conflicts possibly made with the above So Far no effect. ///3 July 2014 SJL

and in my .rootrc

Unix.*.Root.MacroPath: .:$(HOME)/Rootdocs:/opt/local/etc/root/plugins:
#Above calls for the roo macropaths
#Second fraction calls for where they are called
#They are separated by “:” “.” refers to the current directory, Second for Rootdocs and third for the default called from TBrowser

if I try to compile one of the codes written by my professor I get the following error on my personal computer:
g++ -c root-config --cflags app4.cpp
g++ -o runNtuple root-config --glibs app4.o
app4.o: In function main': app4.cpp:(.text+0x70): undefined reference toTFile::TFile(char const*, char const*, char const*, int)'
app4.cpp:(.text+0xcd): undefined reference to TH1F::TH1F(char const*, char const*, int, double, double)' app4.cpp:(.text+0x12a): undefined reference toTH1F::TH1F(char const*, char const*, int, double, double)'
app4.cpp:(.text+0x15b): undefined reference to TNtuple::TNtuple(char const*, char const*, char const*, int)' app4.cpp:(.text+0x32e): undefined reference toTObject::operator delete(void*)‘
app4.cpp:(.text+0x33e): undefined reference to TObject::operator delete(void*)' app4.cpp:(.text+0x34e): undefined reference toTObject::operator delete(void*)‘
app4.cpp:(.text+0x35e): undefined reference to TObject::operator delete(void*)' app4.o: In function__static_initialization_and_destruction_0(int, int)’:
app4.cpp:(.text+0x3db): undefined reference to TVersionCheck::TVersionCheck(int)' app4.o: In functionTObject::operator new(unsigned long)’:
app4.cpp:(.text._ZN7TObjectnwEm[_ZN7TObjectnwEm]+0x14): undefined reference to `TStorage::ObjectAlloc(unsigned long)'
collect2: error: ld returned 1 exit status
make: *** [runNtuple] Error 1

I’ve been told that this has something to do with the environmental variables, I have searched for a solution online for some time and I am yet to find a definite solution…

Any help will be appreciated.
Thank you for your time

Forgot to add, that I can run an independent script by

root -l “example.cpp” so I think I can rule out that I installed ROOT wrong

root-config --cxx --cflags -o runNtuple app4.cpp root-config --glibs

the make file written by my professor is:

#root-config --cxx --cflags-o runNtuple app4.cpproot-config --glibs
$(EXECUTABLE): app4.o
$(CC) -o $@ root-config --glibs app4.o

app4.o: app4.cpp
$(CC) -c root-config --cflags app4.cpp

rm ./*.o ./$(EXECUTABLE)

I think it’s something to do with the library because the makefile works on the lab computer

$(CC) -o $@ root-config --glibs app4.o
$(CC) -o $@ $^ root-config --cflags --glibs

Thank you, that works now. Would you be able to explain the modification made to the makefile please?
I’m a little thrown off by the fact the makefile had to be modified from one computer to the other

You want me to give a “computational course” to your “professor” with special emphases on how one writes makefiles which do not break :question: :mrgreen:
Well, the homework to this particular lesson would be to search the linker’s manual for “–as-needed” and “–no-as-needed” :exclamation: :wink: :mrgreen:

As I’ve mentioned, the makefiles do work with the lab computers. Most of our resources are from example applications that our professor wrote and uploaded on our course website, except other than the first three example applications, everything else does not compile on my personal linux computer.