Release of the program after python is embedded in the C ++ code

Source: Internet
Author: User

A simple program:

 

# 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 it is packaged with py2exe, manually redist/x86/Microsoft. vc90.crt under vs2008 during release
Copy the following four files to the DIST directory generated by py2exe package.
The Dist directory is running in any environment where Python or 08 Runtime Library is not installed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.