c++ - 如何包装 C++Cython 的图书馆?
问题描述
我有一些来自同事的代码,cython.weave
用于包装 C++ 库中的函数:
def partialsort(a, K):
support_code = "#include <algorithm>"
code = "std::partial_sort (&ak(0), &ak(K), &ak(N));"
N = len(a)
ak = a.copy()
vars = ['ak', 'K', 'N']
s = weave.inline(code, vars, support_code=support_code,
type_converters=converters.blitz)
随着 Weave 工具的消失,如果可能的话,我想用 Cython 替换它。到目前为止,我已经根据http://docs.cython.org/en/latest/src/userguide/external_C_code.html尝试了我的运气,并在 Cython 模块中尝试了以下操作,只是为了检查我是否可以访问该库:
cdef extern from "<algorithm>":
pass
当我尝试构建 Cython 模块时,出现以下错误:
csorting.c:604:10: fatal error: algorithm: No such file or `folder
#include <algorithm>
^~~~~~~~~~~
compilation terminated.
据我了解,<algorithm>
是一个 C++ 库。C++ 是这里的问题吗?我有g++
,但 Cython 构建设置使用gcc
. 是<algorithm>
一个必须单独安装的库吗?
解决方案
推荐阅读
- cakephp - 使用 FormHelper::file 时 SecurityComponent 上的 CSRF 错误
- tomcat - Ctrl-c 不使用 Git Bash 停止 Tomcat
- c# - LINQ查询连接表的多个orderby
- android - 为 CognitoCachingCredentialsProvider 指定用户名/密码
- javascript - 打字稿错误 - 类型“字符串 []”不能用作索引类型
- java - 使用 javax.xml.stream.XMLStreamReader 时如何启用非 IANA 编码
- reactjs - 反应日选择器是否有时间选择?
- c++ - 如果带有 char 数组的语句无法正常工作
- c++ - C++ 构造函数和 D'tor 中的类
- corda - 是否有可能在 Corda 的 2 个不同的网络中?