0

I am currently running some Python scripts in a Visual Studio C++ application using the Python/C api. The application is using Python that is installed on my system. However, I'd like to distribute the application without requiring the user to install python manually. I was told to use the embeddable Python version. I found and downloaded the Python 3.8.0 Windows x86-64 embeddable zip file from here. I extracted the contents and now have no idea how to continue. I clearly see the python38.dll (I am assuming this needs to the new dll that the application depends on), but how do I pack it into the output .exe file?

I appreciate the help in advance, and let me know if there is any information I am missing!

pjs
  • 18,696
  • 4
  • 27
  • 56
levente.nas
  • 83
  • 2
  • 10
  • Please read the tag descriptor before using a tag. – pjs Oct 07 '22 at 18:48
  • I am afraid python need to be installed or or some other options from the [similar thread](https://stackoverflow.com/questions/49137/calling-python-from-a-c-program-for-distribution): some parts of the application occasionally call the Python interpreter to run some Python code. – Minxin Yu - MSFT Oct 11 '22 at 07:11

1 Answers1

0

In order to use the Python-C API you need to first import it in your code. This is done by adding #include “Python.h” to your code. However, for this to work you first need to add the python include files to your compiler search directory. In Visual Studio 2019, this is done by adding the include directory from your python install to Properties > C/C++ > General > Additional Include Directories.

Next, you need to add the python library to your linker. Add the libs directory from your python install to Properties > Linker > General > Additional Library Directories.

Lastly, you need to specify the library name to the linker. This is done in Visual Studio by adding the name of the python library (depends on your version of python and is found in {python install directory} \libs) to Properties > Linker > Input > Additional Dependencies.

AbdeeLoS
  • 1
  • 2