I am trying to embed some Python code in C++ with PyBind. Most of documentation is on extending Python with C++, but I am interested in embedding:
On http://pybind11.readthedocs.io/en/stable/advanced/embedding.html there is a simple example with cmake. However for my project I have to extend a makefile.
Is it possible to change this example
cmake_minimum_required(VERSION 3.0)
project(example)
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`
add_executable(example main.cpp)
target_link_libraries(example PRIVATE pybind11::embed)
with this c++ file
#include <pybind11/embed.h> // everything needed for embedding
namespace py = pybind11;
int main() {
py::scoped_interpreter guard{}; // start the interpreter and keep it alive
py::print("Hello, World!"); // use the Python API
}
to a version with a makefile?