undefined symbol: PyExc_ImportError when embedding Python in C

后端 未结 3 1009
慢半拍i
慢半拍i 2020-12-11 18:11

I\'m developing a C shared library that makes a call to a python script. When I run the application I get this error:

Traceback (most recent call last):
  Fi         


        
3条回答
  •  不知归路
    2020-12-11 18:53

    I use such workaround: explicit linking of plugins from lib-dynload directory (it's simply, then explicit dlopen in code). Example with datetime.so:

    cmake:

    SET ( CMAKE_SHARED_LINKER_FLAGS "/usr/lib/python2.7/lib-dynload/datetime.so" )
    

    or just add /usr/lib/python2.7/lib-dynload/datetime.so as linker parameter to gcc in command line:

    g++ -shared -o libfoo.so foo.o -lbar -lzab /usr/lib/python2.7/lib-dynload/datetime.so
    

提交回复
热议问题