I am trying to call Python code in C with this code:
#include <stdio.h>
#include <Python.h>
int main()
{
PyObject* pInt;
Py_Initialize();
PyRun_SimpleString("print('This is Python in C')");
Py_Finalize();
printf("\n");
return 0;
}
and have tried compiling it with this command:
gcc python_test_in_c.c
However it returns an error returns saying:
undefined referance to `__imp __Py_Initialise`
undefined referance to `__imp__PyRun_SimpleSringFlags`
undefined referance to `__imp__Py_Finalise`
collect2.exe: error: ld returned 1 exit status
What is going wrong? How can I fix this?
Any help would be appreciated
P.S I am not sure, but could this be something to do with the fact I copied the Python 'include' file (containing Python.h) in the include file for MinGW located at C:/MinGW
UPDATE: I have now learned this is ok to do but considered bad practice.