c++ - cython c++ 对 std::ios_base::failure 的 undefined reference

标签 c++ python cython

我刚刚编写了 cython 代码就这么简单

# distutils: language = c++

from libcpp.map cimport map,pair
from ios import *



cdef map[int,int] * u = new map[int,int]()

cdef add_item(int n, int x):
    cdef pair[int,int]p = pair[int,int](n,x)
    u.insert(p)

def add(int n, int x):
    add_item(n,x)

添加了构建文件,例如

def make_ext(modname, pyxfilename):
    from distutils.extension import Extension
    return Extension(name=modname,
                     sources=[pyxfilename],
                     language='C++')

并运行简单的脚本,例如

import hello

有线条

导入pyximport pyximport.install()

在我的网站customize.py

在脚本执行时,我得到ImportError:构建模块hello失败:['ImportError:/home/odomontois/.pyxbld/lib.linux-x86_64-2.7/hello.so: undefined symbol :_ZTINSt8ios_base7failureE\n']

c++filt _ZTINSt8ios_base7failureE 打印 std::ios_base::failure 的 typeinfo

是否有可能找出我应该包含哪些目标文件以及如何在我的 pyxbld 文件中执行此操作。

最佳答案

通过添加解决

libraries=["stdc++"]

至 pyxbld

关于c++ - cython c++ 对 std::ios_base::failure 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19703816/

相关文章:

c++ - Cant链接文件系统库con C++

c++ - 多元非线性回归

c++ - 桶排序实现

Python登录多个模块输出两次

numpy - 将 Numpy 数组复制到内存 View

python - 在 cython 文件中导入任何模块会出现 undefined symbol 错误

c++ - 如何从 const float* 中获取 C++ vector

python - signal.spectrogram 返回太多赫兹

python - 一维 np 数组 : how to make it more NumPy-thonic? 上切片的平均值

c++ - gcc 编译的 C++ 中不包含调试符号