I'm trying to find a way to build and run a cpp file with an embedded python interpreter using pybind11.
From this tutorial, it uses CMake but I'm looking for a way to do this without CMake.
Here's what I tried.
In example.cpp:
#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
}
And in the Terminal when I run the following: (builds fine)
c++ -O3 -Wall -std=c++11 -undefined dynamic_lookup `python3 -m pybind11 --includes` example.cpp -o example
And then run the binary with
./example
I get the following error:
dyld: Symbol not found: _PyBaseObject_Type Referenced from: /Users/cuinjune/Desktop/pybindtest/./example Expected in: flat namespace in /Users/cuinjune/Desktop/pybindtest/./example zsh: abort ./example
Is there any possible way to properly build and execute a cpp file with an embedded python interpreter using pybind11? (without using CMake)