I would like to call python script files from my c++ program.
I am not sure that the people I will distribute to will have python installed.
Basically I'm looking for a .lib file that I can use that has an Apache like distribution license.
Create the return value, Restore previous GIL state and return. A reference to an existing Python callable needs to be passed in, to use this function. To do that there are many ways like – simply writing C code to extract a symbol from an existing module or having a callable object passed into an extension module.
It is also possible to embed Python in a C++ program; precisely how this is done will depend on the details of the C++ system used; in general you will need to write the main program in C++, and use the C++ compiler to compile and link your program. There is no need to recompile Python itself using C++.
We can call a C function from Python program using the ctypes module.
I would like to call python script files from my c++ program.
This means that you want to embed Python in your C++ application. As mentioned in Embedding Python in Another Application:
Embedding Python is similar to extending it, but not quite. The difference is that when you extend Python, the main program of the application is still the Python interpreter, while if you embed Python, the main program may have nothing to do with Python — instead, some parts of the application occasionally call the Python interpreter to run some Python code.
I suggest that you first go through Embedding Python in Another Application. Then refer the following examples
Embedding Python in C/C++: Part I
Embedding Python in C/C++: Part II
Embedding Python in Multi-Threaded C/C++ Applications
If you like Boost.Python, you may visit the following links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With