【问题标题】:No such file or directory when I try to include OpenNI.h当我尝试包含 OpenNI.h 时没有这样的文件或目录
【发布时间】:2019-06-26 13:59:50
【问题描述】:

我正在尝试编译一个 cpp 文件,但编译器找不到包含目录。

执行此操作时出现错误:

#include <OpenNI.h>

我已经安装了 OpenNI 及其依赖项,并且正在使用带有 Raspbian 操作系统的 RaspberryPi 3。

我错过了什么?

【问题讨论】:

  • 好吧,您是否打算 (1) 您安装 OpenNI 的状态,以及 (2) 显示您的编译和链接命令有错误?还是让我们继续猜测?

标签: c++ linux compiler-errors include raspbian


【解决方案1】:

您没有告诉编译器在哪里可以找到OpenNI.h 文件。

查找OpenNI.h 的安装位置:

find / -iname OpenNI.h 2> /dev/null

会给你类似/path/to/header/OpenNI.h

然后将此路径添加到您的编译指令中:

gcc -I/path/to/header -c file-using-open-ni.c 

你会在链接时遇到同样的问题,对文件 libOpenNI2.so 做同样的事情

find / -iname OpenNI.h 2> /dev/null

给你/path/to/library

你可以链接到:

gcc file-using-open-ni.o  -L /path/to/library -lOpenNI2 

【讨论】:

  • 我试过了,但是当我执行 find 命令时我什么也没得到。
  • 也许可以尝试使用-iname 而不是-name:它会忽略文件大小写
  • 我已经设法根据您的建议解决了这个问题。我错过了一些路径,所以我添加了它们并且它起作用了。谢谢你的帮助。 @Mathieu
猜你喜欢
  • 2021-10-17
  • 1970-01-01
  • 2013-07-03
  • 2021-12-11
  • 1970-01-01
  • 2013-11-28
  • 2022-08-13
  • 2021-02-06
相关资源
最近更新 更多