In this question and this reference, there are examples of importing c-header files into Cython, but there is no answer to how can one import a .c
file content into Cython.
The .c
file which I am interested to import into Cython for my use is: https://github.com/python/cpython/blob/main/Objects/genobject.c
I have two questions:
One
How do I import a .c
file into Cython?
Two
Do I need to have the .c
file within my directory for it to be accessed? If yes, how do I go about getting https://github.com/python/cpython/blob/main/Objects/genobject.c
so that I can use its content in Cython?
I have two .pxd
files, cpy.pxd
and src.pxd
.
In cpy.pxd
, I have:
cdef extern from "Python.h":
cdef int gen_is_coroutine(object o)
In src.pxd
, I use it as usual:
if gen_is_coroutine(__value):
do_something(__value)
I get this Cython compiler error:
constmeta.obj : error LNK2001: unresolved external symbol gen_is_coroutine
build\lib.win-amd64-cpython-310\cy_src\constmeta.cp310-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120