Otherness
Otherness

Reputation: 405

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. I then switched over to python 3.7.3 and have been having issues with running swig like I was before.

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.

  2. I need to update to a newer version of 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? I'm running Ubuntu, in case that's relevant.

Thanks!

Upvotes: 0

Views: 502

Answers (1)

John Zwinck
John Zwinck

Reputation: 249283

This part is certainly wrong:

-I/usr/include/python2.7

You need to update that to point to your new Python 3.7 installation.

Upvotes: 1

Related Questions