为SWIG指定Python头和库。
I have two versions of python installed 2.7 and 3.3.
我安装了两个版本的python 2.7和3.3。
And when I tried to generate the wrapper with SWIG 1.3.4, I did something like this:
当我尝试用SWIG 1.3.4来生成包装时,我做了如下的事情:
swig -c++ -python -I/opt/rh/python33/root/usr/include/python3.3m mylib.swig
And then, I tried to compile it with g++ 4.6
然后,我试着用g+ 4.6编译它
g++ -L/opt/rh/python33/root/usr/lib64 -Wl,-Bstatic -lz -lboost_date_time-mt -Wl,-Bdynamic -lpython3.3m -lbz2 -lpthread -lrt -ldl -O2 -fPIC -shared mylib_wrap.cxx -I.. -I/opt/rh/python33/root/usr/include/python3.3m -I/server/zodiac/include -std=gnu++0x -o _mylib.so
But then, I got error like this:
但是,我有这样的错误:
mylib_wrap.cxx: In function ‘swig_module_info* SWIG_Python_GetModule()’:
mylib_wrap.cxx:2453:51: error: ‘PyCObject_Import’ was not declared in this scope
mylib_wrap.cxx: In function ‘void SWIG_Python_SetModule(swig_module_info*)’:
mylib_wrap.cxx:2522:92: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
mylib_wrap.cxx: In function ‘swig_type_info* SWIG_Python_TypeQuery(const char*)’:
mylib_wrap.cxx:2545:60: error: ‘PyCObject_AsVoidPtr’ was not declared in this scope
mylib_wrap.cxx:2550:51: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
Then, I looked into Python 2.7's and 3.3's headers. I noticed that those expressions are defined in Python 2.7's headers but not 3.3.
然后,我研究了Python 2.7和3.3的头部。我注意到这些表达式是在Python 2.7的header中定义的,而不是在3.3中定义的。
So it seems to me even though I specified the include path to Python 3.3 when I asked SWIG to generate the wrapper, it still tried to use 2.7.
所以在我看来,即使我指定了Python 3.3的包含路径,当我要求SWIG生成包装器时,它仍然尝试使用2.7。
Any idea how to fix this?
你知道怎么解决这个问题吗?
Thanks!
谢谢!
1 个解决方案
#1
2
SWIG 1.3.4 is ancient. It's not compatible with Python 3.3. You need to use a newer version of SWIG if you want to produce code that is compatible.
痛饮1.3.4是古老的。它与Python 3.3不兼容。如果您想生成兼容的代码,需要使用SWIG的更新版本。
更多相关文章
- Linux安装开发环境,必须配置的环节(Fedora15版本)
- 我已提取并尝试使用启动脚本(./start navicat)来启动 Navicat Linu
- Linux CentOS6环境下MySQL5.1升级至MySQL5.5版本过程
- 我如何理解这个编译器错误:“...的多重定义”
- Linux-2.6 所有版本内核源码下载
- Linux下符号版本原理及实现
- MySQL5.5.22版本安装配置以及基本命令的使用和管理数据库备份与
- 查询自定义VO对象的sql
- Mysql5.7.10版本安装后空密码登录,退出后提示密码错误连接不上解