Import Python DLL into C++

Asked

Viewed 284 times

0

How do I compile a Python class in DLL in order to import it into C++, using Python features that are not available in C++?

I want to be able to import it without having Python installed on the computer

1 answer

6


Python is not a language "compiled", is a language "interpreted", or even programs like py2exe or cx_freeze send a stand-alone version of Python along with the version "python-compiled" in EXE and source (or the pyd which is an intermediate language) of Python probably this internal (it depends on each program, I do not know them in depth).

In other words, it’s kind of impossible to create one. dll from a Python application that does not need Python, unless there is a Python converter for "C" or "C++" that is then compiled in fact, but it would be quite complicated, the work would be so much that it might not even be worth it, it would be easier to write in C++ even.

I can almost safely say that the absence of certain functionality in C++ that you supposedly have in Python can be obtained through . libs or even sources you’ll find in repositories.

There are also programs with a very advanced amount of functionality for C++ such as https://qt.io which has open-source and Enterprise versions. Qt has IDE, SDK and opitional features, compiles for Mingw, MSVC, GCC, has port for Android, iOS or it is a cross-Platform SDK.

I assume your reason for doing this is not "absence only", but yes your familiarity with the language and with projects developed in it, you should know well Python, but not C++ and probably you want to write in Python for already know, I tell you that this path (from my point of view) is the stones, I suggest you or choose to write everything in Python and use programs like:

That will create an executable of your script including a "python stand-alone"

Or else you get Aventure in Qt, which has many functionality in a simplified way to accomplish many things and is still cross-Platform.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.