I am trying to develop c extensions for python, which requires me to use
#include "Python.h"
in the c source code. However, it appears that Python.h in Ubuntu systems can be obtained by downloading python-dev, but this is not an option for macOS.
I tried compiling using /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers/ (which contains a Python.h file) but When I use the command
gcc test.c -I /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers/
I get the following error:
Undefined symbols for architecture arm64:
"_PyObject_Size", referenced from:
_main in test-165478.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Which makes it seem that the Python.h file on my mac is incomplete somehow. Is the solution to this problem downloading the source of python-dev and then using the Python.h header file that is in that package? If so, where could I find the python-dev source code?