Embed a Python interpreter into a C ++ app with pybind11 + cmake

From some time ago, it was possible to easily embed a python interpreter and build an exe with pybind11.

https://pybind11.readthedocs.io/en/stable/advanced/embedding.html

This is useful for programs that are mainly C ++ or whose entry point is C / C ++.

By default, it searches the system and links with libPython found (for example, python in the conda environment for conda, etc.).

If you want to specify Python explicitly

cmake -DPYTHON_EXECUTABLE = / path / to / bin / python ... and PYTHON_EXECUTABLE. (Lib also seems to find it based on the bin directory)

This is because pybind11 internally find_package (PythonInterp).

https://cmake.org/cmake/help/v3.18/module/FindPythonInterp.html

By the way, there are suffixes such as python3.8m, but here is the meaning of suffix.

https://stackoverflow.com/questions/32544974/naming-convention-what-does-the-m-mean-in-libpython3-5m-dylib

TODO

Recommended Posts

Embed a Python interpreter into a C ++ app with pybind11 + cmake
Try embedding Python in a C ++ program with pybind11
Solve ABC163 A ~ C with Python
Solve ABC168 A ~ C with Python
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
Solve ABC158 A ~ C with Python
Pass a list by reference from Python to C ++ with pybind11
Daemonize a Python web app with Supervisor
Use C ++ functions from python with pybind11
Make a desktop app with Python with Electron
Challenge AtCoder (ABC) 164 with Python! A ~ C problem
[Practice] Make a Watson app with Python! # 2 [Translation function]
[Practice] Make a Watson app with Python! # 1 [Language discrimination]
I made a net news notification app with Python
Make a breakpoint on the c layer with python
[AtCoder explanation] Control ABC180 A, B, C problems with Python!
[AtCoder explanation] Control ABC188 A, B, C problems with Python!
ABC163 C problem with python3
[AtCoder explanation] Control ABC158 A, B, C problems with Python!
Debug with PEPPER python interpreter
Make a fortune with Python
Create a directory with python
ABC188 C problem with python3
[AtCoder explanation] Control ABC164 A, B, C problems with Python!
[AtCoder explanation] Control ABC168 A, B, C problems with Python!
ABC187 C problem with python
Make multiple numerical elevation data into a single picture with Python
Make a scraping app with Python + Django + AWS and change jobs
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
[Python] What is a with statement?
Operate a receipt printer with python
A python graphing manual with Matplotlib.
Call C from Python with DragonFFI
Create Awaitable with Python / C API
ABC127 A, B, C Explanation (python)
Let's make a GUI with python.
Solve ABC166 A ~ D with Python
ABC166 in Python A ~ C problem
Create a virtual environment with Python!
I made a fortune with Python.
Building a virtual environment with Python 3
Creating a simple app with flask
Make a recommender system with python
Solve ABC036 A ~ C in Python
Solved AtCoder ABC 114 C-755 with Python3
[Python] Generate a password with Slackbot
ABC128 A, B, C commentary (python)
ABC126 A, B, C Explanation (python)
Let's make a graph with python! !!
Solve ABC037 A ~ C in Python
[Python] Inherit a class with class variables
I made a daemon with Python
Write a batch script with Python3.5 ~
[AtCoder explanation] Control the A, B, C problems of ABC182 with Python!
Deploy a Python app on Google App Engine and integrate it with GitHub
[AtCoder explanation] Control the A, B, C problems of ABC186 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC185 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC187 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC184 with Python!
[Pyenv] Building a python environment with ubuntu 16.04