我正在从事一个需要在 cython 中进行大量字典查找的项目。为了尝试提高速度,我尝试用 libcpp 中的 unordered_maps 替换字典。
#!python
#cython: boundscheck=False, wraparound=False, infer_types=True,cdivision = True
from libcpp.unordered_map cimport unordered_map
但是,当我尝试在命令行上使用 gcc 进行编译时,编译失败并显示
CAStar2.c:482:19: fatal error: utility: No such file or directory
#include <utility>
^
compilation terminated.
编译器似乎无法找到多个所需的文件。
我如何将它指向那些文件?
最佳答案
cython 生成的 C 文件需要通过 setuptools Extension
编译。
如果手动编译,则还需要手动指定 setuptools 否则会使用的所有 include 和 lib 目录。
参见 cython setuptools documentation here和 here for a minimal compile from cmd line example .
关于python - 在 Cython 中使用/编译 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46394412/