Hi!
I’m trying to compile a C++ program written for ROOT with a Makefile I created.
I’ve installed the last version of ROOT on Ubuntu 17.04. The root files are in the Download/root-6.08.06 directory.
These are the Makefile commands:
ROOTCFLAGS:= root-config --cflags
ROOTLFLAGS:= root-config --glibs
root: root.o
**(LINK.cc) **(ROOTCFLAGS) **(ROOTLFLAGS) **(@F).o -o **(@F)
root.o: root.cpp
**(LINK.cc) ***(ROOTCFLAGS) -c * *.cpp -o $(@F)
clean:
rm *.o
Before executing “make root” I go to the root directory and type . bin/thisroot.sh, which should set all the necessary ambient variables to root directories.
If I try in the bash root-config --cflags and root-config --glibs I get the right paths to the /include and /lib directories.
However this is what I get:
make root
g++ -std=c++11root-config --cflags
-c root.cpp -o root.o
g++ -std=c++11root-config --cflags
root-config --glibs
root.o -o root
root.o: In functiongraph_thread(void*)': root.cpp:(.text+0x5ab): undefined reference to
TThread::Lock()’
root.cpp:(.text+0x5d4): undefined reference toTGraph::TGraph(int, double const*, double const*)' root.cpp:(.text+0x5e3): undefined reference to
TGraph::SetTitle(char const*)’
root.cpp:(.text+0x604): undefined reference toTGraph::TGraph(int, double const*, double const*)' root.cpp:(.text+0x613): undefined reference to
TGraph::SetTitle(char const*)’
root.cpp:(.text+0x633): undefined reference toTText::TText(double, double, char const*)' root.cpp:(.text+0x638): undefined reference to
TThread::UnLock()’
root.cpp:(.text+0x648): undefined reference toTGraph::SetMaximum(double)' root.cpp:(.text+0x66c): undefined reference to
TGraph::Draw(char const*)’
root.cpp:(.text+0x67b): undefined reference toTObject::Draw(char const*)' root.cpp:(.text+0x69f): undefined reference to
TGraph::Draw(char const*)’
root.cpp:(.text+0x6e2): undefined reference toTObject::Draw(char const*)' root.cpp:(.text+0x720): undefined reference to
TQObject::Emit(char const*)’
root.cpp:(.text+0x7a0): undefined reference toTText::~TText()' root.cpp:(.text+0x7a8): undefined reference to
TGraph::~TGraph()’
root.cpp:(.text+0x7b0): undefined reference toTGraph::~TGraph()' root.cpp:(.text+0x9b3): undefined reference to
TGraph::~TGraph()’
root.cpp:(.text+0x9c0): undefined reference toTGraph::~TGraph()' root.cpp:(.text+0x9cd): undefined reference to
TText::~TText()’
root.o: In functionTPad::Modified(bool)': root.cpp:(.text._ZN4TPad8ModifiedEb[_ZN4TPad8ModifiedEb]+0x25): undefined reference to
TQObject::Emit(char const*)’
root.o: In functionTCanvasImp::IsA() const': root.cpp:(.text._ZNK10TCanvasImp3IsAEv[_ZNK10TCanvasImp3IsAEv]+0x1): undefined reference to
TCanvasImp::Class()’
root.o: In functionTCanvasImp::ShowMembers(TMemberInspector&) const': root.cpp:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0xd): undefined reference to
TCanvasImp::Class()’
root.cpp:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x21): undefined reference toROOT::Class_ShowMembers(TClass*, void const*, TMemberInspector&)' root.o: In function
TApplicationImp::ShowMembers(TMemberInspector&) const’:
root.cpp:(.text._ZNK15TApplicationImp11ShowMembersER16TMemberInspector[_ZNK15TApplicationImp11ShowMembersER16TMemberInspector]+0xd): undefined reference toTApplicationImp::Class()' root.cpp:(.text._ZNK15TApplicationImp11ShowMembersER16TMemberInspector[_ZNK15TApplicationImp11ShowMembersER16TMemberInspector]+0x21): undefined reference to
ROOT::Class_ShowMembers(TClass*, void const*, TMemberInspector&)’
root.o: In functionTApplicationImp::IsA() const': root.cpp:(.text._ZNK15TApplicationImp3IsAEv[_ZNK15TApplicationImp3IsAEv]+0x1): undefined reference to
TApplicationImp::Class()’
root.o: In function_GLOBAL__sub_I_canvas': root.cpp:(.text.startup+0x11): undefined reference to
TVersionCheck::TVersionCheck(int)’
root.o: In functionmain': root.cpp:(.text.startup+0xd1): undefined reference to
TApplication::TApplication(char const*, int*, char**, void*, int)’
root.cpp:(.text.startup+0xdb): undefined reference toTStorage::ObjectAlloc(unsigned long)' root.cpp:(.text.startup+0xfb): undefined reference to
TCanvas::TCanvas(char const*, char const*, int, int)’
root.cpp:(.text.startup+0x121): undefined reference toTPad::Divide(int, int, float, float, int)' root.cpp:(.text.startup+0x147): undefined reference to
TThread::TThread(char const*, void* ()(void), void*, TThread::EPriority)’
root.cpp:(.text.startup+0x151): undefined reference toTThread::Run(void*)' root.cpp:(.text.startup+0x15e): undefined reference to
TApplication::Run(bool)’
root.cpp:(.text.startup+0x163): undefined reference toTThread::SetCancelAsynchronous()' root.cpp:(.text.startup+0x16b): undefined reference to
TThread::Kill()’
root.cpp:(.text.startup+0x17f): undefined reference toTThread::~TThread()' root.cpp:(.text.startup+0x187): undefined reference to
TApplication::~TApplication()’
root.cpp:(.text.startup+0x1e6): undefined reference toTObject::operator delete(void*)' root.cpp:(.text.startup+0x1ee): undefined reference to
TApplication::~TApplication()’
root.cpp:(.text.startup+0x206): undefined reference toTThread::~TThread()' root.o: In function
TApplicationImp::~TApplicationImp()‘:
root.cpp:(.text._ZN15TApplicationImpD2Ev[_ZN15TApplicationImpD5Ev]+0x10): undefined reference toTString::~TString()' root.o: In function
TApplicationImp::~TApplicationImp()’:
root.cpp:(.text._ZN15TApplicationImpD0Ev[_ZN15TApplicationImpD5Ev]+0x14): undefined reference toTString::~TString()' root.o:(.data.rel.ro._ZTV15TApplicationImp[_ZTV15TApplicationImp]+0x80): undefined reference to
TApplicationImp::Streamer(TBuffer&)’
root.o:(.data.rel.ro._ZTV10TCanvasImp[_ZTV10TCanvasImp]+0x100): undefined reference to `TCanvasImp::Streamer(TBuffer&)’
collect2: error: ld returned 1 exit status
Makefile:44: recipe for target ‘root’ failed
make: *** [root] Error 1
I’ve tried to fix it in the last two days but I didn’t manage to do anything. I haven’t even found a solution in the forum.
Thanks anyone who can help me!