QTRSensors.h: No such file or directory
编译时找不到 QTRSensors.h,说明还没有安装提供它的库:QTRSensors(作者 pololu)。
完整报错通常长这样
fatal error: QTRSensors.h: No such file or directorycompilation terminated.Arduino IDE 里安装
- 菜单「工具 → 管理库」,或按
Ctrl+Shift+I。 - 搜索框输入
QTRSensors。 - 在结果里找作者为 pololu 的那一个,点「安装」。如果弹窗问是否一起安装依赖库,选「全部安装」。
- 重新编译。
PlatformIO 里安装
在 platformio.ini 对应的环境下加一行,保存后重新编译,会自动下载:
lib_deps = pololu/QTRSensors@^4.0.0命令行(Arduino CLI)
arduino-cli lib install "QTRSensors"关于这个库
Arduino library for the Pololu QTR Reflectance Sensors. This is a library for an Arduino-compatible controller that interfaces with the Pololu QTR reflectance s
最新版本:4.0.0 · 支持:所有平台 · 被 2 个库依赖
装了还是报错?
- 装错了同名库:库管理器里常有好几个名字相近的库,确认作者是 pololu。同样提供
QTRSensors.h的还有:pololu/ZumoShield,示例代码用的是哪一个,就装哪一个。 - 开发板不支持:这个库支持 所有平台。换成不支持的板子时,即使装上也可能编译出错。
- 缺依赖库:报错里出现新的「No such file」时,再按同样的方法装那个头文件对应的库。板伴可以一次识别所有缺失的头文件。
- 大小写不对:Linux 和 macOS 区分大小写,
#include里的文件名要和QTRSensors.h完全一致。
pololu 的其他常用库
板伴 Boardly · 给硬件初学者的免费排错工具。内容依据公开资料整理,尚未逐条经过实物验证,请以实际测量为准。