I embedded a python interpreter in C++ code. It works fine for the high-level way with:
PyRun_SimpleFileEx(fd, "/file_path/some_script.py", 1)
But I need to pass some arguments to the python code so I tried to go forward with some code from the python documentation about embedding. However, XCode complains about some functions that are not defined. My guess is that my
#include <Python/Python.h>
Does not add the right python version and is pointing possibly to the system version (2.7) which doesn't have the headers with the right functions.
My linker Flags are:
-lpython3.7m -ldl -framework CoreFoundation
I added the Python include folder from the framework to the header search paths:
../../Support/Lib/Python/include
and the Python Lib folder from the framework to the library search paths:
../../Support/Lib/Python/lib
The support folder is like indicated to folders up from the solution.
The functions that XCode cannot find are PyUnicode_DecodeFSDefault()
and Py_FinalizeEx()
.
The first one is defined in unicodeobject.h
that gets included by Python.h
its right where it has to be in the include folder as I described above.
I'm not sure what I'm doing wrong, so maybe someone can point me in the right direction. Thanks in advance!