gpt4 book ai didi

import - SWIG 导入错误 : undefined symbol: _Py_RefTotal

转载 作者:行者123 更新时间:2023-12-04 14:43:03 25 4
gpt4 key购买 nike

我是 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

最佳答案

我有一个类似的问题,谷歌把我送到这里 - 我想我会发布我的解决方案。

对我来说,编译器对使用 C 还是 C++ 感到困惑。

因为我打算编写 c++,所以我遵循了示例,但使用了 swing -c++ 选项并使用 g++ 而不是 gcc 作为编译器。

但是,我的构建工具(boost.build 或 bjam)看到“example.c”并正在编译

g++ -x c -O2 -fPIC -c example.c

“-x c”标志指定 c 代码,由于文件扩展名为 example.c,bjam 将其包括在内。这导致链接以与帮助请求类似的方式崩溃。

我将“example.c”的名称更改为“example.cpp”(使用 bjam 时删除了 -x c 标志),然后链接继续进行。

我花了一点时间才发现这一点,所以也许有一天我可以为别人节省 30 分钟。

祝福

汤姆

关于import - SWIG 导入错误 : undefined symbol: _Py_RefTotal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3480995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com