running c++ code from python

前端 未结 4 607
日久生厌
日久生厌 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:25

    A couple of other options besides Boost.python are SIP and SWIG (Simplified Wrapper and Interface Generator). Like Boost, SIP and SWIG are open source.

    SWIG is particularly powerful, but also a bit hairy. It provides support for interfacing C and C++ with a boatload of other languages including (not a complete list) Python, Perl, Lua, Tcl/Tk, Ocaml, Ruby, Java. One aspect of SWIG is that it parses your C++ headers. This has benefits and pitfalls. A benefit is that it does most of the work of generating the interfaces. A downside is that it doesn't handle some of the dark corners of C++ 2003, and it hasn't stepped up to C++11 at all. Another downside is that compilation of a large project becomes slow. Very, very slow.

提交回复
热议问题