I'm trying to run my Cython project. And one of the header is gmpxx.h
.
Even though I already installed the gmp library using brew install gmp
. I could not run my cython file with python3 setup.py build_ext --inplace
.
fatal error: 'gmpxx.h' file not found
#include <gmpxx.h>
^~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
So I use brew list gmp
to check the location of the gmpxx.h
header.
So it is actually inside /opt/homebrew/Cellar/gmp/6.3.0/include/
folder.
With Xcode
, I can just add the location into the header search paths
.
But I'm trying to do the same thing with Pycharm
.
How do I add the location of my gmpxx.h header to pycharm?
I need a little help. Please kindly give me your take. Thank you.
So I added the library location directly into setup.py file.
from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
extension = Extension(
"Class Name",
sources=["Something"
],
include_dirs=[
"/opt/homebrew/Cellar/gmp/6.3.0/include", # Include directory for GMP headers
"/opt/homebrew/Cellar/gmp/6.3.0/include/gmp", # Additional include directory for GMP headers
],
libraries=["gmpxx", "gmp"],
library_dirs=[
"/opt/homebrew/Cellar/gmp/6.3.0/lib", # Directory containing libgmpxx.dylib
],
extra_compile_args=["-std=c++17", "-O3"],
language="c++"
)
setup(
name="Class Name",
version="0.1",
packages=find_packages(where="src"),
package_dir={"": "src"},
package_data={"Class Name": ["*.pyi"]},
ext_modules=cythonize(extension,
compiler_directives={"language_level":3},
annotate=True),
zip_safe=False
)