You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用CMake和Pybind11构建Python Wheel时出现头文件包含错误

Pybind11 C++项目打包pip包时头文件包含错误问题

我正尝试为带有Pybind11 Python绑定的C++项目制作pip包,但每次执行python3 -m build构建wheel时都会出现头文件包含错误,尝试多种方法都无法解决。

已尝试的操作

项目结构1

src/
   header1.hpp
   header2.hpp
   mainheader.hpp
   mainfile.cpp
   pythonbindings.cpp

在mainheader.hpp中尝试过以下头文件包含写法:

  • #include "header1.hpp"
  • #include "src/header1.hpp"
  • #include "./header1.hpp"
    构建时报错找不到mainheader.hpp。

项目结构2(由cookiecutter C++项目生成)

include/
   header1.hpp
   header2.hpp
   mainheader.hpp
python/
   pythonbindings.cpp
src/
   mainfile.cpp

构建时报错找不到header1.hpp。

若需要查看我的CMake、setup.py或pyproject.toml文件,请告知,我会提供。

内容的提问来源于stack exchange,提问作者Deepflea18

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 16:57:04