问题
I am writting a program which uses boost python embedded. My program works no problem on Linux Mint but on Windows its a huge pain. I am using MingW so I tried creating an import lib following instructions from another question on this site. With all that in mind the program compiled and linked, python34 dynamically and boost python statically. My program crashes though and I cant tell for the life of me why, I followed the execution and it stops at: "import("main");"
// My python extensions
PyImport_AppendInittab("OpenGL", PyInit_OpenGL);
PyImport_AppendInittab("glm", PyInit_glm);
PyImport_AppendInittab("glfw", PyInit_glfw);
cout << "Initializing Python... ";
Py_Initialize();
cout << "done\n";
using namespace boost::python;
main_module = import("__main__"); // < crashes at this line
main_namespace = main_module.attr("__dict__");
Magically enough I removed the libpython34.a from my lib search path and the program still built fine, so I assume that the issue may not exactly be with python itself, but I'm out of ideas for where to look for the issue. I can't get any detailed information about the error thats occuring cause the program just quits and prints nothing, and I have exceptions in place to catch error_already_set : / If you have suggestions or anything really please share, thanks!
Edit: I built this simple python hello world embedded program
PyImport_ImportModule("__main__");
PyRun_SimpleString("from time import time,ctime\n"
"print('Today is',ctime(time())\n)");
Py_Finalize();
This worked flawlessly. On the other hand:
boost::python::import("__main__");
Caused a silent crash.
来源:https://stackoverflow.com/questions/24986361/boost-python-on-windows-crashes-at-import-main