I am working on a Python code embedding in c++ helloworld program, necessary additional include/library directories are properly set up.
When I use Local Windows Debugger, it shows "Hello World" correctly. But if I double click project.exe, it says project.exe has stopped working.
Does anyone know what kind of configurations or steps to make so that project.exe
shows "Hello World" when double clicked??
Code goes like the following:
main.cpp
#include <iostream>
#include <Python.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
int main()
{
Py_Initialize();
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append('./')");
PyObject *pModule = PyImport_ImportModule("helloworld");
PyObject *pFunc = PyObject_GetAttrString(pModule, "printHello");
PyEval_CallObject(pFunc, NULL);
Py_Finalize();
return 0;
}
helloworld.py
def printHello():
print("Hello World!")