If you directly use the python module exported by this program in the execution program, you do not need to export it to the PYD library.

Source: Internet
Author: User

IfProgramDirectly use the python module exported by this program, you do not need to export it to the PYD library.

For example, if program A has its Python extension module named exta, after calling the initialization function initexta () of the exta module in program, you can directly use the exta module method in the program. As follows:Code:

 
# Include <python. h> # include <boost/python. HPP> using namespace boost: Python; void testpy () {printf ("Hello world \ n") ;}// generate the export module boost_python_module (exta) {def ("testpy", testpy);} int _ tmain (INT argc, _ tchar * argv []) {py_initialize (); initexta (); pyrun_simplestring ("Import exta"); // use the exta module pyrun_simplestring ("exta. testpy () "); py_finalize (); System (" pause "); Return 0 ;}

This method saves the need for additional dynamic Connection Library export projects. If you do not want your program to be attached with too many dynamic connection libraries, this section is a very convenient method.

Sometimes function declaration is used to facilitate use in other program modules. Therefore, the void initxxx () Declaration must be put into the header file. Note: The initxxx function in the boost: Python library is prototype: extern "C" _ declspec (dllexport) void initxxx ();


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.