swig no module named _example

前端 未结 3 737
感动是毒
感动是毒 2021-02-15 12:38

I cannot reproduce the basic SWIG example on windows. My error is stated in the SWIG docs and I am sure that I do the 2 fixes they mention. For this error:

>&         


        
3条回答
  •  眼角桃花
    2021-02-15 13:33

    I found you have to rename the library file that C++ generates from .dll to .pyd on windows. I can't recall if you need to rename it on apple. and your function that you want to expose to python has to have extern "C" preceding it. Otherwise the compiler doesn't make the function accessible outside the library. Also If I recall you need to wrap the return values in a Py_value if you want to use them in python.

提交回复
热议问题