OpenCV - 找不到'cstdint'文件



我使用的是Mac 10.10和OpenCV 3.0,当我在编译我的项目时,我得到了这个错误:

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

之后,我将c++标准库更改为libstdc++,出现了另一个错误:

/usr/local/include/opencv2/hal/defs.h:271:14: 'cstdint'文件未找到

希望有人能帮助我

根据这个问题的顶部答案,有两种方法可以解决这个问题,关于这个事实,你正在使用macOs和你的默认编译器是Clang。你可以使用:

#include <tr1/cstdint>

#include <stdint.h>

而不是cstdint,这是libc++的一部分。

我在尝试将为c++编写的头文件(.h)导入某些Objective C代码(.m)时遇到了这个问题。

我的解决方案是创建一个中间的Objective c++文件(.mm)和头文件,导入c++头文件,然后导出C兼容的包装函数。

头文件中有类似这样的内容,以使其与Objective-C (.m)代码兼容

#if defined(__cplusplus)
extern "C" {
#endif
const char *MyNewFunction(void); // or whatever
#if defined(__cplusplus)
}
#endif

(感谢Dave Hylands帮我弄明白了这一切)

最新更新