How to use .so

Try to use my c++ code into root make me very frustrating. I can’t generate dictionary with some liker errors.

Info in <TUnixSystem::ACLiC>: creating shared library /gpfs/storage_4/users/home/turra/diphoton/utils/filemanager/./filemanager_cpp.so
dlopen error: /gpfs/storage_4/users/home/turra/diphoton/utils/filemanager/./filemanager_cpp.so: undefined symbol: _ZNK11FileManager19get_iterator_periodESs
Load Error: Failed to load Dynamic link library /gpfs/storage_4/users/home/turra/diphoton/utils/filemanager/./filemanager_cpp.so
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/gpfs/storage_4/users/home/turra/diphoton/utils/filemanager/filemanager_cpp_ACLiC_dict.o: In function `G__filemanager_cpp_ACLiC_dict_3158_0_8(G__value*, char const*, G__param*, int)':
filemanager_cpp_ACLiC_dict.cxx:(.text+0x5094): undefined reference to `FileManager::get_iterator_period(std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
/gpfs/storage_4/users/home/turra/diphoton/utils/filemanager/filemanager_cpp_ACLiC_dict.o: In function `G__filemanager_cpp_ACLiC_dict_3158_0_14(G__value*, char const*, G__param*, int)':
filemanager_cpp_ACLiC_dict.cxx:(.text+0x58a2): undefined reference to `FileManager::get_filename_period(std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
/gpfs/storage_4/users/home/turra/diphoton/utils/filemanager/filemanager_cpp_ACLiC_dict.o: In function `G__filemanager_cpp_ACLiC_dict_3158_0_20(G__value*, char const*, G__param*, int)':
filemanager_cpp_ACLiC_dict.cxx:(.text+0x5d2e): undefined reference to `FileManager::get_chain_period(std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
collect2: ld returned 1 exit status
*** Interpreter error recovered ***

fun think: after this error root generate a filemanager_cpp.so and filemanager_cpp.d and this is fun because if ld fail how can produce a .so? Next, exit and restart ROOT.

root [0] .L filemanager.cpp+
root [1] FileManager manager("xxx")

and it magically works!

So I manually generated a shared object, with:

g++ -Wl,-soname,filemanager.so -shared -L/gpfs/storage_4/users/home/proof/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lz -pthread -lm -ldl -rdynamic -lm -ldl -rdynamic -fPIC filemanager.o

but how to use it?

root [2] gSystem->Load("filemanager.so")
(int)0

root [3] FileManager manager("x")
Error: Function FileManagermanager("x") is not defined in current scope  (tmpfile):1:
*** Interpreter error recovered ***

I attach the code, maybe someone can find a better solution
filemanager.cpp (8.26 KB)
filemanager.h (3.19 KB)

Hi,

when using ACliC a dictionary will be generated automatically for you and linked as part of the .so. To make sure that the .so is complete (no undefined functions) ACliC is also trying to build an executable using the .so and here it fails in your case with the message:

and some more. Please make sure that those functions are implemented. The .so seems to work in this case as long as you don’t hit any of the undefined methods.

In the case where you build yourself the .so you miss the dictionary, so you cannot execute any filemanager commands from the ROOT prompt.

Cheers, Fons.

[quote=“rdm”]Hi,

when using ACliC a dictionary will be generated automatically for you and linked as part of the .so. To make sure that the .so is complete (no undefined functions) ACliC is also trying to build an executable using the .so and here it fails in your case with the message:

and some more. Please make sure that those functions are implemented. The .so seems to work in this case as long as you don’t hit any of the undefined methods.
[/quote]

Ops, this is the problem. But I don’t understand, why the linker fail? I’m not calling these not implemented functions. For example if I compile manually an example.cpp that use Filemanager, but doesn’t use unimplemented methods, it works. And also the manual .so generation works.

[quote=“rdm”]
In the case where you build yourself the .so you miss the dictionary, so you cannot execute any filemanager commands from the ROOT prompt.
Cheers, Fons.[/quote]

Ok, thank you very much.

Hi,

this is exactly why ACliC tries to build an executable, to find out if the .so defines all symbols. This to avoid run-time surprises when using the .so in ROOT.

Cheers, Fons.

[quote] I’m not calling these not implemented functions.[/quote]Yes, but ACLiC generates a dictionary for your classes, including these functions and the dictionary is calling these functions.

Cheers,
Philippe.