Static Compiling of Root v6.xx


Can anyone one offer any advice on how to statically compile ROOT libraries? I am using CMake to build on MacOS 10.10, and turned the BUILD_SHARED_LIBS to OFF, but still the static libraries (libTree.a etc… ) are not built.

Any ideas…


Building ROOT with static libraries is supported yet with CMake. In order to do this I would like to get a good idea of the different use cases. Can you explain why are you interested with it?


I am currently making use of ROOT in an external application and wanted to link ROOT statically to this application, rather than having to bundle an entire distribution of ROOT (or a link to it). I don’t know if this is even possible in the same way that I can statically link to Geant4/VTK etc. My application makes use of Geant4/ITK/VTK and also some file handling, histogramming and graph fitting functionality from root (but nothing graphical ).


I had tried using “configure” rather than CMake. Then using the “make static” option I get this error with 6.04.

clang++ -O2 -DNDEBUG -m64 -mmacosx-version-min=10.10 -stdlib=libc++ -Wl,-E -o bin/roota main/src/rmain.o -Wl,–no-as-needed -Wl,–whole-archive lib/libRoot.a -Wl,–as-needed -Wl,–no-whole-archive -lm -lpthread -ldl -L/opt/SOURCE/ROOT/6.04.02/interpreter/llvm/inst/lib -lclangFrontend -lclangSerialization -lclangDriver -lclangCodeGen -lclangParse -lclangSema -lclangAnalysis -lclangAST -lclangEdit -lclangLex -lclangBasic -lLLVMObjCARCOpts -lLLVMInstrumentation -lLLVMipo -lLLVMVectorize -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMTarget -lLLVMOrcJIT -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMBitWriter -lLLVMCore -lLLVMSupport -L/opt/SOURCE/ROOT/6.04.02/interpreter/llvm/inst/lib -lz -ledit -lcurses -lm lib/libpcre.a lib/libfreetype.a -lz -lssl -lcrypto -framework Cocoa -framework OpenGL -lz -L/usr/local/lib -llzma
ld: unknown option: -E


Ultimately, I have a working solution for making use of some of the ROOT functionality in my standalone application. However, I only make use of TFile and TH2D to store data from a Geant simulation. I link to the ROOT shared libraries, but it seems that this is not enough and I effectively need to distribute the entire ROOT distribution along with my application because there seems to be other dependencies on dictionaries/plugins etc.

Is there a way in which I only need to distribution for example libCore, libTree, libHist with my application and that’s it? I don’t know if I am missing something, but there is very little documentation which really discusses building against ROOT to develop something that is standalone.

I link in VTK/ITK/GEANT and I only need to distribute the relevant *.dylib files (macOS) along with my compiled binary… but ROOT is giving me a real headache and it doesn’t appear anywhere near as straightforward.


Is is exactly my question about understanding the use cases since the static libraries would not be enough. ROOT requires a minimal installation and environment. For example the directories /fonts, /etc, etc.
I have made some progress in creating the static libraries but now I need to check what is actually requiring from the environment.

I am also interested by using static ROOT libraries.
For my case, I developped a Qt application that create ROOT files that contain a TTree. I tried to compile my software using ROOT static libs but I did not manage to with ROOT 5.34. CINT was needed (I do not know why) and as it does not exist a static lib of CINT, I had to use the dynamic libs.

So if you plan to improve this part, I would be interested to have separate part of ROOT for static libs (libTree.a, libHist.a, …).