Почему компилятор gcc не находит функцию Py_Initialize?

есть код на C:

#include <stdio.h>
#include <Python.h>

int main() {
  Py_Initialize();
  PyRun_SimpleString("print('Hello!')");
  Py_Finalize();
}

При компиляции программы командой:

gcc -o first_test.exe first_test.c -I C:\Python39\include -L C:\Python39\libs -l python39

Лезут следующие ворнинги:

In file included from C:\Python39\include/Python.h:85, from first_test.c:2: C:\Python39\include/pytime.h:123:59: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration 123 | PyAPI_FUNC(int) _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv); | ^~~~~~~ C:\Python39\include/pytime.h:130:

12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration 130 |
struct timeval *tv, | ^~~~~~~ C:\Python39\include/pytime.h:135:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration 135 | struct timeval *tv,

И следующие ошибки:

c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\grett\AppData\Local\Temp\ccjh99I1.o:first_test.c:(.text+0xf): undefined reference to _imp__Py_Initialize' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\grett\AppData\Local\Temp\ccjh99I1.o:first_test.c:(.text+0x25): undefined reference to _imp__PyRun_SimpleStringFlags' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\grett\AppData\Local\Temp\ccjh99I1.o:first_test.c:(.text+0x2c): undefined reference to _imp__Py_Finalize collect2.exe: error: ld returned 1 exit status

Помогите пожалуйста разобраться с проблемой!


Ответы (0 шт):