Skip to content

Instantly share code, notes, and snippets.

@phaustin
Created May 28, 2019 20:56
Show Gist options
  • Save phaustin/ae173e90ec09ce294b59886b9e6a6c9c to your computer and use it in GitHub Desktop.
Save phaustin/ae173e90ec09ce294b59886b9e6a6c9c to your computer and use it in GitHub Desktop.
cmake find python
I am trying to embedd a python script with my C++ executable. I am using the instructions here: https://github.com/zooba/ogre3d-python-embed/blob/master/EmbeddingPython.md
I have pybind installed, I have used the embedded installation of python 3.7.3 and followed the dependency installation step such that if i use the python install adjactent to my executable, my deps load properly.
I believe i am having trouble getting pybind to actually use THIS installation of python. Can anyone point me toward anything i'm missing here? i would have assumed it would have looked adjacent to the executable but i know nothing.

Boris Staletic @bstaletic May 26 23:26
@faultfactory Configure your -DPYTHON_LIBRARY and -DPYTHON_INCLUDE_DIR.

Sergei Izmailov @sizmailov May 27 00:43
@faultfactory If you are using cmake<3.12 in addition you may want to ensure match of libraries to python interpreter by next snippet
find_package(PythonInterp REQUIRED)
find_package(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED )
If you are using cmake >=3.12 try FindPython https://cmake.org/cmake/help/v3.14/module/FindPython.html
find_package (Python COMPONENTS Interpreter Development)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment