'How compile c code with python header file

I downloaded python source code using the command

 git clone https://github.com/python/cpython

Now I created a main.c like so

#include <stdio.h>
#include <python.h>

int main(void)
{
    
    return 0;
}

when I try to compile using this command

gcc main.c -L /f/<redacted>/cpython/Lib -I /f/<redacted>/cpython/Include  -lpython

I get this error

$ gcc main.c -L /f/<redacted>/cpython/Lib -I /f/<redacted>/cpython/Include  -lpython
In file included from main.c:2:
F:/<redacted>/cpython/Include/python.h:12:10: fatal error: pyconfig.h: No such file or directory
   12 | #include "pyconfig.h"
      |          ^~~~~~~~~~~~
compilation terminated.

I know that pyconfig.h can be obtained using sudo apt install python-dev on Linux, so I tried pacman -S python-devel but this does not seem to fix the issue

I also tried to use locate pyconfig.h to link it using the -I but it is nowhere to be found

My machine is a windows 10 and I am using MSYS2withMINGW64 to compile this code



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source