A simpleProgram:
View plaincopy to clipboardprint?
- # Include "Boost/python. HPP"
- Int_ Tmain (IntArgc, _ tchar * argv [])
- {
- Py_initialize ();
- Pyrun_simplestring ("Print 'hello '");
- Py_finalize ();
- System ("Pause");
- Return0;
- }
# Include "Boost/python. HPP "</P> <p> int _ tmain (INT argc, _ tchar * argv []) <br/>{< br/> py_initialize (); <br/> pyrun_simplestring ("Print 'hello'"); <br/> py_finalize (); <br/> system ("pause"); <br/> return 0; <br/>}< br/>
No problem. But I still cannot run it in an XP environment (XP is in a virtual machine, except that the driver is not installed in msdn ). I have installed vc2005 Runtime Library in XP, python26.dll, boost_python-vc80-mt-1_39.dll, boost_python-vc80-mt-gd-1_39.dll are copied to the directory where the program is located or not. The program is released by release. The prompt is displayed as soon as you run the command:
Application initialization (0xc0150002) fails. Click OK to terminate the application.
Google was fruitless for half a day.
This morning, I ran a python program packaged in py2exe under xp. Because it is for2.6, We need to install the Runtime Library of vc2008, I ran the C ++ applet yesterday.
But there are still errors. After I pack py2exeand then decompress library.zip to complete the operation! I used python to access the database in C ++, and the operation was also okay!
It seems that it is better to embed Python C ++ programs in the future without vc8 writing. Just use pure C ++.
PS: If py2exe is used for packaging, manually redist/x86/Microsoft. all the four files under vc90.crt are copied to the DIST directory generated by the py2exe package. You can directly copy the DIST directory to any environment without Python or 08 runtime libraries installed.