views:

43

answers:

1

Hi there,

I have a c99 function that uses openmp, which works as expected. I also wrote a ptyhon interface using ctypes which causes the problem. Ctypes/python can not find the library for openmp. Here is the error massage:

File "foo.py", line 2, in <module>
    foobar=cdll.LoadLibrary("./libfoo.so")
  File "/usr/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: ./libfoo.so: undefined symbol: GOMP_parallel_end

And I use these cmds:

gcc -fPIC -std=c99 -lm -Wall -fopenmp -pedantic -c foo.c
gcc -shared -o libfoo.so foo.o
python foo.py

I already googled and found a ''solution'' online, but I don't understand what is meant with:

I suppose I should set restype on constructors to ctypes.c_void_p.
And that I should set the corresponding types in argtypes on called
functions to ctypes.c_void_p. Will this cause necessary conversions
to take place? I'd like some confirmation that this is the right way
to approach this situation.

What does the solution mean or do you know an other way?

[update]

So here is the correct cmd line options with the help from Iulian Şerbănoiu:

gcc -fPIC -std=c99 -lm -Wall -fopenmp -pedantic -c foo.c
gcc -shared -lgomp -lrt  -o libfoo.so foo.o
python foo.py
A: 

Try adding -lgomp option in order to link with openmp library. From here.

Iulian Şerbănoiu