Home | News | Documentation | Download

ROOT libraries for Eclipse Keplar not recognised

_ROOT Version: 6.22.06
_Platform: linux (ubuntu) cinnamon mint
_Compiler:


I have followed the following instruction on how to integrate ROOT for eclipse :

i had a previous centos setup and it worked. My current machine is linux cinamon mint (ubuntu) and i cant get it working.

i end up with the following error

01:15:36 **** Build of configuration Debug for project roottest ****
make all
Building file: …/src/roottest.cpp
Invoking: GCC C++ Compiler
g++ -I/home/joel/phd/git/root/v6.22.06/normal/root/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"src/roottest.d" -MT"src/roottest.o" -o “src/roottest.o” “…/src/roottest.cpp”
Finished building: …/src/roottest.cpp

Building target: roottest
Invoking: GCC C++ Linker
g++ -L/home/joel/phd/git/root/v6.22.06/normal/root/lib -Xlinker -L/usr/local/lib /home/joel/phd/git/root/v6.22.06/normal/root/bin/root-config --libs --glibs --cflags --ldflags --auxlibs --auxcflags -pthread -lm -ldl -o “roottest” ./src/roottest.o
/usr/bin/ld: ./src/roottest.o: in function main': /home/joel/eclipse-workspace/roottest/Debug/../src/roottest.cpp:26: undefined reference to TCanvas::TCanvas(char const*, char const*, int, int)’
/usr/bin/ld: /home/joel/eclipse-workspace/roottest/Debug/…/src/roottest.cpp:28: undefined reference to TH1F::TH1F(char const*, char const*, int, double, double)' /usr/bin/ld: /home/joel/eclipse-workspace/roottest/Debug/../src/roottest.cpp:26: undefined reference to TObject::operator delete(void*)’
/usr/bin/ld: /home/joel/eclipse-workspace/roottest/Debug/…/src/roottest.cpp:28: undefined reference to TObject::operator delete(void*)' /usr/bin/ld: ./src/roottest.o: in function __static_initialization_and_destruction_0(int, int)’:
/home/joel/phd/git/root/v6.22.06/normal/root/include/TVersionCheck.h:31: undefined reference to TVersionCheck::TVersionCheck(int)' /usr/bin/ld: ./src/roottest.o: in function TObject::operator new(unsigned long)’:
/home/joel/phd/git/root/v6.22.06/normal/root/include/TObject.h:152: undefined reference to `TStorage::ObjectAlloc(unsigned long)’
collect2: error: ld returned 1 exit status
make: *** [makefile:47: roottest] Error 1
“make all” terminated with exit code 2. Build might be incomplete.

As far as i can see all the libraries and header files do exist in the project but eclipse cant seem to find them.

can anyone tell me how to fix this?

edit::

even if i remove any ROOT related functionality ::

#include <TCanvas.h>
#include <TH1.h>
#include

using namespace std;

int main() {
cout << “!!!Hello ROOT!!!” << endl; // prints !!!Hello World!!!
//TCanvas *c1 = new TCanvas(“c1”, “test”, 600, 600);

//TH1F *hist = new TH1F("test", "test", 100, 0, 1);
//hist->Fill(0.1);
//hist->Fill(0.5);

// hist->Draw();

//c1->SaveAs("test.png");

//delete c1;
return 0;

}

i get the following error::

01:34:58 **** Incremental Build of configuration Debug for project roottest ****
make all
Building target: roottest
Invoking: GCC C++ Linker
g++ -L/home/joel/phd/git/root/v6.22.06/normal/root/lib -Xlinker -L/usr/local/lib /home/joel/phd/git/root/v6.22.06/normal/root/bin/root-config --libs --glibs --cflags --ldflags --auxlibs --auxcflags -pthread -lm -ldl -o “roottest” ./src/roottest.o
/usr/bin/ld: ./src/roottest.o: in function __static_initialization_and_destruction_0(int, int)': /home/joel/phd/git/root/v6.22.06/normal/root/include/TVersionCheck.h:31: undefined reference to TVersionCheck::TVersionCheck(int)’
collect2: error: ld returned 1 exit status
make: *** [makefile:47: roottest] Error 1
“make all” terminated with exit code 2. Build might be incomplete.

As far as i can see the variables (USER_OBJS) (LIBS) dont seem to get populated in the makefile thats auto generated

g++ -L/home/joel/phd/git/root/v6.22.06/normal/root/lib -Xlinker -L/usr/local/lib /home/joel/phd/git/root/v6.22.06/normal/root/bin/root-config --libs --glibs --cflags --ldflags --auxlibs --auxcflags -pthread -lm -ldl -o “roottest” (OBJS) (USER_OBJS) $(LIBS)

Hello, and welcome to the ROOT forum!

The tutorial seems to have slightly outdated build instructions. Can you build ROOT following our current build instructions?

i have built root using the link mention, but i am still getting same issue as the original post

Let me invite @Axel and @StephanH, they might have an idea regarding the Eclipse+ROOT integration.

Already the #include causes “usage” and means you need to provide ROOT’s libraries. The .o needs to come first, /root-config --glibs after: the linker goes left to right and ignores libraries that do not provide symbols needed at that point. The need is created by passing the .o to the linker. Does that help?

alright perfect that worked.

Just for anyone elses benefit, what axel said is correct, the varables (OBJS) (USER_OBJS) $(LIBS) in the make file need to sit before the -xlinker.

we can do this by changing the “command line pattern” in eclipse.

Simply go to -> properties-> c/c++ build ->settings -> GCC c++ linker.
and under the command line pattern field move the ${FLAG} to the end