A
A
Andrei1penguin12021-01-07 14:37:54
Python
Andrei1penguin1, 2021-01-07 14:37:54

How to recompile python to mingw?

Good day, I have a task to run the following python code from C:

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

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

But when compiling the program with the command gcc -IC:\Python39\include -LC:\Python39\libs first_test.c -o first_test.exe -l python39 I get
an error about the impossibility to find the functions Py_Initialize(), PyRun_SimpleString() and Py_Finalize()
I think that the problem is that the mingw compiler simply does not see the python sources, because python itself is built on a different compiler and I think that building python on the mingw compiler will help solve the problem
Can you please tell me how can I build python on mingw?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2021-01-07
@Andrei1penguin1

because python itself is built on a different compiler
no.
Perhaps the bitness of gcc and python (x32,x64) does not match.
Your example was successfully built for me, though on python 3.4.
Instead of MinGW I use TDM-GCC 9.2.0 x32
5ff7178634d56649146639.png

D
dvska, 2021-01-14
@dvska

Do not be perverted, install (L) Ubuntu Linux.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question