Skip to content

PYBIND11_EMBEDDED_MODULE(example, m) compile error #3536

Answered by sphaero
sphaero asked this question in Q&A
Discussion options

You must be logged in to vote

To answer my own question: it seems you need to include embed.h for it to work:

#include <pybind11/pybind11.h>
#include <pybind11/embed.h>

namespace py = pybind11;

int add(int i, int j) {
   return i * j;
}

PYBIND11_EMBEDDED_MODULE(example, m) {
    m.doc() = "pybind11 example plugin"; // optional module docstring

    m.def("add", &add, "A function which adds two numbers");
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sphaero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant