I want to execute a code helloword.cpp which takes in some argument from console parses those arguments and then prints "hello world" in the console.
Now, I want to parse these arguments from a python scripts parsearguments.py
So for example:
def parse_arguments:
...# some code
return arguments
Now, how do i communicate between python and c++. I have been reading and see that cython, boost python are the options but I have a hard time finding the right simple hello world example.
Any suggestions will be appreciated. Thanks
To execute C++ code in python, you could effectively use boost python, here is a tutorial: http://www.boost.org/doc/libs/1_59_0/libs/python/doc/index.html You write a kind of wrapper outside you C++ code.
If it is C code, python has internal library called ctypes.
In both case, you should compile the C/C++ code into shared library.
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