简体   繁体   中英

Writing a python wrapper for c++ code

I modified a C++ code (Kraskov_v1.C) and I now wish to call it from Python.

I am able to convert the C++ code (Kraskov_v1.C) into a .so file and integrate it into my python library. However when I try and import the library, it throws up an error. The error says "undefined symbol: _Z8mir_xnynPPdiiiiS_S_S_"

mir_xn_yn is a function (written in another c++ file namely miutils) that my Kraskov_v1 code calls. I included the header file

include "miutils.h"

in my file containing Kraskov_v1.

Here is the setup.py file I wrote to build and install this package.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy.distutils.misc_util

setup(name='Kraskov_v1',
      version='0.1.0',
      ext_modules=[Extension('_Kraskov_v1',sources =        
      ["Kraskov_v1.i","Kraskov_v1.C"],
      include_dirs = ['src'])
      ])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Can someone tell me whats wrong? I am new to python and c++ and would appreciate some help.

The Extension needs a list of libraries to link with after compiling.

Missing symbols means a required library is not linked to the shared object ( .so ) and definitions from that library are not available.

setup(name='Kraskov_v1',
      version='0.1.0',
      ext_modules=[Extension('_Kraskov_v1',sources =        
          ["Kraskov_v1.i","Kraskov_v1.C"],
          include_dirs = ['src']),
          libraries=['kraskov', <..>],
      ])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM