3

cython を使用してモジュールをコンパイルしようとしていますが、コンパイラは外部 c ファイルにインクルード ライブラリを見つけることができません (例として使用しますが、 、、cmathなどの必要な他のライブラリにも同じ問題があります)。cstdiocstdintcstring

最小限の例は、次の 4 つの単純なファイルで構成されています。

cfile.c:

#include <cmath>

test_pxd.pxd:

cdef extern from "cfile.c":
    pass

test.pyx:

cimport test_pxd

setup.py:

from distutils.core import Extension, setup
from Cython.Build import cythonize

sources = ['test.pyx']

extension = [Extension('test',sources)]

setup(ext_modules=cythonize(extension,force=True))

私が実行した場合setup.py

 python3 setup.py build_ext --inplace

エラーが発生します:

cfile.c:1:17: 致命的なエラー: cmath: そのようなファイルまたはディレクトリはありません

c ファイルを直接コンパイルするだけで (たとえばg++ -c cfile.c.

cython のコンパイラに(および、cmath、 などの他の)ライブラリを外部 c ファイルで検索させるにはどうすればよいですか?cstdiocstdintcstring

4

1 に答える 1