简体   繁体   English

python 和 swig 版本兼容性问题

[英]Issue with python and swig version compatibility

I was previously working with python 2.7.9 to wrap some c++ code using swig (version 2.0.12) and everything was working well.我之前正在使用 python 2.7.9 使用 swig(版本 2.0.12)包装一些 c++ 代码,并且一切正常。 I then switched over to python 3.7.3 and have been having issues with running swig like I was before.然后我切换到 python 3.7.3 并且像以前一样在运行 swig 时遇到问题。

This is my error message in my terminal:这是我的终端中的错误消息:

ImportError: /home/_add_array.so: undefined symbol: PyClass_Type

I can imagine two possible solutions:我可以想象两种可能的解决方案:

  1. The command line commands I'm making to get swig to generate files need to be changed.需要更改我为使 swig 生成文件而使用的命令行命令。

  2. I need to update to a newer version of swig.我需要更新到更新版本的 swig。

If it's case 1, what about my previous commands aren't correct:如果是第一种情况,我以前的命令不正确怎么办:

swig -c++ -python add_array.i
g++ -fpic -c add_array_wrap.cxx add_array.h add_array.cpp -I/usr/include/python2.7
g++ -shared add_array_wrap.o add_array.o -o _add_array.so

If it's case 2, what version of swig is compatible with python 3.7.3?如果是情况2,什么版本的swig兼容python 3.7.3? I'm running Ubuntu, in case that's relevant.我正在运行 Ubuntu,以防万一。

Thanks!谢谢!

This part is certainly wrong:这部分肯定是错误的:

-I/usr/include/python2.7

You need to update that to point to your new Python 3.7 installation.您需要更新它以指向您的新 Python 3.7 安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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