Invoke root class in Qt Project

I try to invoke root class in Qt project, but most of them failed.

by add some cmd in the .pro file

LIBS += \

QMAKE_PRE_LINK += /usr/local/opt/root6/bin/root-config --cflags --libs

and source code

#include "TMath.h"

successfully, it works. But, that’s all. When I try to include other class, TString ,for example, it breakdown.

symbol(s) not found for architecture x86_64
linker command failded with exit code 1(use -v to see invocation)

Have you ever met this case? Thank you~

some codes attached below.

I don’t think it works as you intend to.
Most probably, root-config will be called before linking but no qmake variables will be changed.
You should add list of used ROOT libraries to LIBS

1 Like

Great! It works, Thanks so much!

follow your suggestion, I delete QMAKE_PRE_LINK code, and append the lib.

LIBS += \
    -L/usr/local/opt/root6/lib -lCore -lImt -lRIO -lNet -lHist -lGraf \
    -lGraf3d -lGpad -lTree -lTreePlayer -lRint -lPostscript -lMatrix \
    -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic

Now, TFile, TString, TTree work well. Previously,I have try similar ways, but failed, maybe arising from improper settings. Anyway, thanks again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.