參考資訊:
https://stackoverflow.com/questions/24174394/cmake-is-not-able-to-find-python-libraries
問題如下:
-- pybind11 v2.6.3 dev1 -- Found PythonInterp: /usr/bin/python3 (found version "3.11.2") -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.11.2", minimum required is "3.6") -- Check for installed Python Interpreter -- found -- Python module install path: lib/python3/dist-packages CMake Error at /usr/local/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find PythonLibs (missing: PYTHON_INCLUDE_DIRS) (Required is at least version "3.6") Call Stack (most recent call first): /usr/local/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE) CMakeModules/FindPythonLibs.cmake:261 (find_package_handle_standard_args) CMakeLists.txt:815 (find_package)
解法如下:
$ cmake .. \ -DPYTHON_INCLUDE_DIR=$(python -c "import sysconfig; print(sysconfig.get_path('include'))") \ -DPYTHON_LIBRARY=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")