1

I and my friend are working on the same project which is a pretty big so we split the project. Everything is ok till now but the real problem is that my friend has written the code in C++ but I have written the code in python now some of the functions that I have written will depend on those that he wrote. Like if I wrote GUI of a calculator using python and the addition logic is written in C++.

How can we link this two programs to get the desired output?

Adrian Mole
  • 30,672
  • 69
  • 32
  • 52
  • You can use Python's C API to bridge both parts of your software. Also consider using a library that helps you with the bindings (otherwise it's a lot of tedious labour), e.g. PyBind11 or Boost Python. – lubgr Jul 25 '20 at 15:01

1 Answers1

1

There are different possible solutions to this problem, depending on how complex your requirements are.

If it is possible to make a C wrapper for the C++ functions you want to call from the Python side, ctypes may be an option. If the Python program needs access to a more complex C++ API, have look at swig, Boost.Python or PyBind11 (thanks to @lubgr for mentioning the latter). If the C++ code, however, is accessible through a command line program, and it is sufficient for your case to run it that way from Python, look here.

Doc Brown
  • 18,656
  • 6
  • 48
  • 86