C ++ script with python

I have a C ++ program, and I want to implement scripts on it. Desired scenario: I have C ++ executable code, then it calls the python script at a certain time so that it knows what to do through the built-in interpreter, and the script then uses some form of API from the C ++ program. Here I ran into a problem. To expose C ++ code in python, you need to compile the DLL wrapper that you want and load it as a module inside python, and this will break my intent of python by accessing executable functions.

Is there any way to solve this problem without resorting to putting so many pieces of C ++ into a shared library?

+4
source share
1 answer

What you want to do is paste Python code into your application. There is an article on python.org about how to do this using the original CPython, but it's not that difficult when it comes to C ++. The best bet may be to use Boost.Python or SWIG .

+4
source

Source: https://habr.com/ru/post/1395103/


All Articles