Standalone binary linked with static library

Hi, all

I have been suffering from running a standalone root binary which was linked with static root library named “libRoot.a”.

I have been using hsimple.cxx (found in ROOTSYS/test) for this trial.
The compile commands (compile.sh) looks like following

g++ -O -Wall -fPIC -pthread -I/home/jwshin/apps/root/5.15.06/include/root -c hsimple.cxx
g++ -O  hsimple.o -L/home/jwshin/apps/root/5.15.06/lib/root -lRoot -lpcre -lm -ldl -o hsimple

In local, hsimple run and produced the output with no problems.
However, when it was copied to other machine on which no root library were installed, it crashed during invoking hfile.Write() with following error messages.

*** Break *** segmentation violation
sh: /home/jwshin/apps/root/5.15.06/etc/gdb-backtrace.sh: No such file or directory

It was strange to me because if the standalone executable was linked with root’s static library,
I thought there are no root dependencies any more and then it is possible to be executed over GRID or a cluster.

I think that in order to write a root object ( TH, Tree and etc) to a TFile, certain information( in system.rootrc. I guess) should be needed.
If that, is there any solution to embed the information ?

Thanks in advance.

2 machines have to be almost identical in regard to architecture ( 32-bit, 64-bit), OS and system libraries.

You did not mention any info about the machines. hard to figure what’s going on.

You might compile debug version of ROOT and a program and then it would tell you what’s going on in more detail instead of simply seg fault.

Hello,
Were you able to solve your problem? I tried doing the same procedure you did and cannot even get hsimple to compile initially. I changed the build to:

g++ -O -Wall -fPIC -pthread -I/home/ROOT-STATIC-BUILD/include -c hsimple.cxx g++ -O hsimple.o -L/home/ROOT-STATIC-BUILD/lib -lRoot \ -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -o hsimple

and it compiled. However, executing it (on the same computer) leads to a bunch of errors:

[quote]~/root-standalone> ./hsimple
Warning in TClassTable::Add: class TPosixThreadFactory already in TClassTable
Warning in TClassTable::Add: class TPosixThread already in TClassTable
Warning in TClassTable::Add: class TPosixMutex already in TClassTable
Warning in TClassTable::Add: class TPosixCondition already in TClassTable


Warning in TClassTable::Add: class reverse_iterator<vector<int,allocator >::iterator> already in TClassTable
Error in TPluginManager::FindHandler: Cannot find plugin handler for TVirtualStreamerInfo! Does $ROOTSYS/etc/plugins/TVirtualStreamerInfo exist?

*** Break *** segmentation violation
sh: /home/karthik/etc/gdb-backtrace.sh: not found
*** glibc detected *** ./hsimple: double free or corruption (!prev): 0x0000000003079080 ***[/quote]

I would be interested in knowing how you solved the problem.

Thanks
Karthik.

[quote=“jungwook”]Hi, all

I have been suffering from running a standalone root binary which was linked with static root library named “libRoot.a”.

I have been using hsimple.cxx (found in ROOTSYS/test) for this trial.
The compile commands (compile.sh) looks like following

g++ -O -Wall -fPIC -pthread -I/home/jwshin/apps/root/5.15.06/include/root -c hsimple.cxx
g++ -O  hsimple.o -L/home/jwshin/apps/root/5.15.06/lib/root -lRoot -lpcre -lm -ldl -o hsimple

In local, hsimple run and produced the output with no problems.
However, when it was copied to other machine on which no root library were installed, it crashed during invoking hfile.Write() with following error messages.

*** Break *** segmentation violation
sh: /home/jwshin/apps/root/5.15.06/etc/gdb-backtrace.sh: No such file or directory

It was strange to me because if the standalone executable was linked with root’s static library,
I thought there are no root dependencies any more and then it is possible to be executed over GRID or a cluster.

I think that in order to write a root object ( TH, Tree and etc) to a TFile, certain information( in system.rootrc. I guess) should be needed.
If that, is there any solution to embed the information ?

Thanks in advance.[/quote]

Hi,

Your link line since to be try to link to both the static library (-lRoot) and the shared library (-lCore etc.). In addition when linking against the static library you need to explicitly request the inclusion of the dictionary into you executable by adding: rootulibs="-Wl,-u,_G__cpp_setupG__Net \ -Wl,-u,_G__cpp_setupG__IO \ -Wl,-u,_G__cpp_setupG__Hist \ -Wl,-u,_G__cpp_setupG__Graf \ -Wl,-u,_G__cpp_setupG__G3D \ -Wl,-u,_G__cpp_setupG__GPad \ -Wl,-u,_G__cpp_setupG__Tree \ -Wl,-u,_G__cpp_setupG__Thread \ -Wl,-u,_G__cpp_setupG__Rint \ -Wl,-u,_G__cpp_setupG__PostScript \ -Wl,-u,_G__cpp_setupG__Matrix \ -Wl,-u,_G__cpp_setupG__Physics"

Cheers,
Philippe.