running c++ code from python

前端 未结 4 678
日久生厌
日久生厌 2021-02-06 05:39

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 pa

4条回答
  •  一向
    一向 (楼主)
    2021-02-06 06:08

    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.

提交回复
热议问题