Compilation problem, error _ZN4Vc_16Common11RandomStateE

Hi

I have a c++ root code that I want to compile it, make a shared library and use it in a python code.

I am using ROOT 6.32. My c++ code basically just use TRandom3 and TF1, and I am trying to compile this way:

g++ -c -L/usr/local/lib -I/usr/local/include  -Iinterface/  src/TrigEmulatorTool.cc src/TrigEmulator.cc -fPIC -std=c++20
g++ -shared -o TrigEmulatorTool.so TrigEmulatorTool.o

and I get a shared library TrigEmulatorTool.so without errors.

However, when I tried to load this library in python, just like:

import ctypes
ctypes.cdll.LoadLibrary("/srv/src/TriggerEmulator/TrigEmulatorTool.so")

I am getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/ctypes/__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "/usr/local/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /srv/src/TriggerEmulator/TrigEmulatorTool.so: undefined symbol: _ZN4Vc_16Common11RandomStateE

Any idea what can be the reason?
cheers


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.32.02
Platform: Linux
Compiler: linuxx8664gcc


Hello @alefisico,
just to double check, are you sure your ROOT lib path is included in LD_LIBRARY_PATH?

Cheers,
Monica

ok, I discovered the root-config commands. And just in case, I leave the solution to my problem. I had to compile it as:

$(root-config --cxx --cflags) -Iinterface/  src/TrigEmulatorTool.cc $(root-config --libs) -fPIC -shared -o TrigEmulatorTool.so

and now it works.

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