首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Cmake find_package没有找到Pybind11,即使有提示?

Cmake find_package没有找到Pybind11,即使有提示?
EN

Stack Overflow用户
提问于 2022-11-07 01:57:56
回答 2查看 44关注 0票数 -2

我试图在一个Cmake项目中使用Pybind11。我使用的是Cmake3.23.0-Rc2。

为了包括它,我可以做以下几点:

find_package(pybind11 REQUIRED)

但是,这在我的机器上不起作用。因此,我试图按照用户指南给find_package一个提示:

代码语言:javascript
运行
复制
SET(pybind11_DIR, "C:/Users/tyler.shellberg/AppData/Local/Programs/Python/Python37/Lib/site-packages/pybind11")

这也没用。Cmake建议它可能需要像pybind11Config.cmake这样的文件的特定位置。所以,我试着说得更具体些:

代码语言:javascript
运行
复制
SET(pybind11_DIR, "C:/Users/tyler.shellberg/AppData/Local/Programs/Python/Python37/Lib/site-packages/pybind11/share/cmake/pybind11")

这也没用。我在Cmake中得到了完全相同的错误:

代码语言:javascript
运行
复制
CMake Error at lib/(our project name)/CMakeLists.txt:30 (find_package):
  By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "pybind11",
  but CMake did not find one.

  Could not find a package configuration file provided by "pybind11" with any
  of the following names:

    pybind11Config.cmake
    pybind11-config.cmake

  Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
  "pybind11_DIR" to a directory containing one of the above files.  If
  "pybind11" provides a separate development package or SDK, be sure it has
  been installed.

我仔细检查了一下,就可以找到Python本身:

代码语言:javascript
运行
复制
Python_FOUND:TRUE
Python_VERSION:3.7.4
Python_Development_FOUND:TRUE
Python_LIBRARIES:C:/Users/tyler.shellberg/AppData/Local/Programs/Python/Python37/libs/python37.lib
Python_INCLUDE_DIRS:

(尽管奇怪的是,include_dirs是空的)

我做错了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-11-07 07:42:12

一种方法是先找到Python3,然后使用站点作为提示:

代码语言:javascript
运行
复制
find_package(Python3 REQUIRED)
find_package(pybind11 REQUIRED HINTS "${Python3_SITELIB}")
票数 1
EN

Stack Overflow用户

发布于 2022-11-07 02:03:43

pip install "pybind11[global]"修好了。它可能不是推荐的,但它是有效的。从这里找到建议:How to make cmake find pybind11

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74341221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档