Linking with libRoot.a


I’m am trying to link my application statically with Root.
I need to use the XMLParser functionallity and that wasn’t included automatically in libRoot.a, so I tried to recompile libRoot.a to include the TXMLParser.o, TDOMParser.o, TXMLNode.o, TXMLAttr.o and TXMLDocument.o files. This appeared to work but when I try to link it to my application I get numerous errors related to these objects. Such as:

/root/root/lib/libRoot.a(TXMLParser.o): In function `TXMLParser::StopParser()':
TXMLParser.cxx:(.text+0x1b0): undefined reference to `xmlStopParser'
/root/root/lib/libRoot.a(TXMLParser.o): In function `TXMLParser::ReleaseUnderlying()':
TXMLParser.cxx:(.text+0x2af): undefined reference to `xmlFreeParserCtxt'

I am running the following command to attempt to make the application:

g++ -O2 -m32 roxieMAIN.o roxieXML.o roxieGUI.o -L/root/root/lib -lRoot -lpcre -ldl -o roxieDraw

Any suggestions would be greatly appreciated.

Best Reagrds,


you should probably also link against libxml2.

Cheers, Axel.

Fantastic, thanks Axel.

That has cleared up all the errors related to XML, there are still a few errors from libRoot.a(TTF.o) I don’t even know what that is, let alone what its dependancies might be.

Here is a few of the errors with TTF.o:

/root/root/lib/libRoot.a(TTF.o): In function `TTF::Version(int&, int&, int&)':
TTF.cxx:(.text+0x2a3): undefined reference to `FT_Library_Version'
/root/root/lib/libRoot.a(TTF.o): In function `TTF::Cleanup()':
TTF.cxx:(.text+0x97a): undefined reference to `FT_Done_Face'
TTF.cxx:(.text+0x9af): undefined reference to `FT_Done_FreeType'
/root/root/lib/libRoot.a(TTF.o): In function `TTF::SetTextSize(float)':
TTF.cxx:(.text+0xbdf): undefined reference to `FT_Set_Char_Size'
/root/root/lib/libRoot.a(TTF.o): In function `TTF::SetTextFont(char const*, int)':
TTF.cxx:(.text+0xdd8): undefined reference to `FT_New_Face'
TTF.cxx:(.text+0xe0f): undefined reference to `FT_Done_Face'
TTF.cxx:(.text+0xec9): undefined reference to `FT_Set_Transform'

Do you know what else I need to link to prevent these errors?


To add a bit more information, this is now my make command:

I have seperated out the XMLParser from libRoot.a and compiled it into libXMLParser.a (I am assuming that the .a is being used, not the .so of the same name as I have -static in the command)
It turns out that libxml2.a also depends on libz.a and libm.a

I have tried linking against every static library I can find in /usr/lib to fix the problem in my previous post but non of them helped.

I am completely out of ideas, I have no clue what TTF.o wants.


I have spent days on this problem now… does anyone have any idea what the dependancies of TTF.o might be? This is driving me crazy.


OK, I’ve solved one problem, TTF depends upon freetype. So, the application now compiles statically using this command:

Istill get a bunch of warnings like:

/root/root/lib/libRoot.a(shl.o): In function `G__dlopen': shl.cxx:(.text+0x279a): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

And, at runtime I get a seg fault with the error:

dlopen error: /root/root/lib/ undefined symbol: _ZNK7TObject7DoErrorEiPKcS1_Pc Load Error: Failed to load Dynamic link library /root/root/lib/ Error in <TCint::AutoLoad>: failure loading library for class TGX11 Error in <TPluginHandler::SetupCallEnv>: class TGX11 not found in plugin GX11 *** Interpreter error recovered *** *** Break *** segmentation violation

Does anyone have any ideas how to solve this?
I’ve checked in libRoot.a and TGX11.o is included. I even tried compiling it statically on it’s own into libGX11.a and linking against it but that made no difference.

Thanks in advance,



have a look how $ROOTSYS/bin/roota is linked when doing “make static”, you see:

lib/libRoot.a -lXpm -lXext -lX11 -lXft -lm -ldl -pthread -rdynamic -lpcre -lfreetype -lz -lncurses

add to this the -lxml2 and XMLParser that you may need. Check if roota works for you. Your own app should work in the same way.

Cheers, Fons.

Fantastic! It compiles fine and runs without that library error now, thanks.
I’m still getting a Seg fault but it possible there is a bug in my code. Although, it runs fine when linked non-statically.

Thanks for your help.