I'm using Python 3.8.5 (64-bit) and Dev-C++ (Code generation ISO C++11, Includes Python's include folder and Libraries also has Python's Lib folder).
I designed a very simple and barebones ttk GUI in Python and all I need is for my .cpp to call the GUI and send and receive data from it.
So far, I've noticed I need #include <Python.h>
and to use Py_Initialize();
and Py_Finalize();
for something.
I'm aware that I can call the .cpp from the Python GUI's source file, but my teacher wants it the other way around.
Is there any way to accomplish this?
Edit 1: For example, if I run the following code:
#include <iostream>
#include <Python.h>
using namespace std;
int main()
{
Py_Initialize();
cout << Py_GetVersion() << endl;
PyRun_SimpleString("print('C++ back-end & Python front-end')");
Py_Finalize();
return 1;
}
Then I get the error: Python-C++.cpp:(.text+0x10): undefined reference to `__imp_Py_Initialize', GetVersion, SimpleStringFlags and for Finalize too.
Can I do it in Visual Studio? I'm tearing my hair out here.
Edit 2: I got Embedded Python to work in Visual Studio. Now, how do I import my Interface.Py with my .cpp and how do I use it as a GUI?