Embedding Python in C++ without linking libpython: Recommended but not explained? #3697
-
I've read the documentation at https://pybind11.readthedocs.io/en/stable/compiling.html a few times and googled for a few hours, but I'm still missing a solution to this (seemingly) simple task. The documentation recommends exactly what I would like to do:
Now the problem is that it does not describe how this should be done with cmake (or is it possible I overlooked it?). When I just remove Through lots of searching I found flags like Now I'm getting quite frustrated: Why is the documentation recommending something and then not giving any hints as to how that goal can be achieved? Am I overlooking something, or am I on the wrong track? On a side note, I do not think its a good idea to ignore all undefined symbols. This was recommended on some obscure web pages. But that seems really bad practice and its therefore not a path I have followed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This section of the doc applies to extension modules only. They are plugins and it's the responsibility of the host application, python, to provide those symbols (by linking libpython). When you embed Python you are creating your own host application that can load (import) extension modules. So it has to link libpython, that is after all where the runtime is implemented. |
Beta Was this translation helpful? Give feedback.
This section of the doc applies to extension modules only. They are plugins and it's the responsibility of the host application, python, to provide those symbols (by linking libpython). When you embed Python you are creating your own host application that can load (import) extension modules. So it has to link libpython, that is after all where the runtime is implemented.