我对SWIG还是个新手。我尝试编译SWIG中给出的示例,但得到以下错误:
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import example
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "example.py", line 25, in <module>
_example = swig_import_helper()
File "example.py", line 21, in swig_import_helper
_mod = imp.load_module('_example', fp, pathname, description)
ImportError: ./_example.so: undefined symbol: _Py_RefTotal发布于 2010-10-28 01:25:37
我也遇到了类似的问题,google把我派到了这里--我想我应该把我的解决方案发布出来。
对我来说,编译器对使用c还是c++感到困惑。
由于我打算编写c++,所以我遵循了示例,但使用了swing -c++选项,并使用g++而不是gcc作为编译器。
然而,我的构建工具(boost.build,或bjam)看到的是"example.c“,并且正在使用
g++ -x c -O2 -fPIC -c example.c
“example.c”标志指定c代码,bjam包含该代码是因为-x的文件扩展名为example.c。这会导致链接以类似于帮助请求的方式崩溃。
我将"example.c“的名称更改为"example.cpp”(在使用bjam时会删除-x c标志),然后链接就可以正常进行了。
我花了一小段时间才发现这一点,所以也许有一天我会为某人节省30分钟。
祝福
汤姆
发布于 2017-01-07 01:06:38
您忘记将-lpython2.6添加到链接器语句中。
https://stackoverflow.com/questions/3480995
复制相似问题