Home | News | Documentation | Download

Using PyRoot "symbol lookup error"

Dear all.

normally I don’t use ROOT or C++ in my work, but I have a C++ ROOT script I would like to use.
When I run the script with root script.cpp it works correctly.
I created a header file which contains the function I want to call and compiled the C++ file into a library.
Then I call the whole thing using:

ROOT.gInterpreter.ProcessLine('#include "header.h"')
riccardoLib = ROOT.gSystem.Load('./Library.o')
ROOT.function()

The code runs fine up to a certain point when I get the following error:

python: symbol lookup error: /directory_of_the_script /Library.o: undefined symbol: _ZN4ROOT4Math12InterpolatorC1ERKSt6vectorIdSaIdEES6_NS0_13Interpolation4TypeE

I did some digging in the code to see where it crashes exactly and I found this function call to be the cause:

gMinuit->mnexcm("CALL FCN", arglist ,1,ierflg);

which is strange because before then the mnexcm function is already called (larger sniplet):

gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
	
	for (UInt_t i=0;i<NDATA;i++){
		Char_t str[10];
		sprintf(str,"Ek%d",i);
		minuit.mnparm(i,str, start[i], step[i], Efitmin,Efitmax, ierflg);
	}
		gMinuit->mnexcm("CALL FCN", arglist ,1,ierflg);

Hope you can help me fix this error. :slight_smile:

In case you need it info on my System:
I have conda 4.8.3 with Python 3.7.8 installed and created a ROOT environment (Root 6.22/02) as described in the install guide. I am using Ubuntu 18.04.2.

Maybe @moneta can take a look

Hi,

I don’t understand the error you are getting. Can you please post the files and the information needed to reproduce this error ?

Lorenzo

Here is the full code:

data.txt (2.5 KB) runPython.py (1.5 KB) test2.cpp (5.9 KB) test2.h (390 Bytes)

I create the library with

g++ -g -shared -fPIC test2.cpp `root-config --cflags --glibs` -o test2.o 

Then execute runPython.py. Code runs until line 223 in test2.cpp and then gives me the error with Math/Interpolator, but it looks as if the same function ran fine just a couple of lines before …

Hi,
Thank you. I can reproduce your problem.
When you compile your program you need to add -lMathMore , since ROOT::Math::Interpolator is part of the MathMore library.
Doing this it worked for me:

g++ -g -shared -fPIC test2.cpp `root-config --cflags --glibs` -lMathMore  -o test2.o

Lorenzo

1 Like

Great that fixed it for me as well. Thanks!

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