简体   繁体   English

OpenCV - 找不到“cstdint”文件

[英]OpenCV - 'cstdint' file not found

I'm using Mac 10.10 and OpenCV 3.0, when I was compiling my project I got this error:我使用的是 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)

After that, I changed the c++ standard library to libstdc++, another error appeared:之后,我把c++标准库改成了libstdc++,又出现了一个错误:

/usr/local/include/opencv2/hal/defs.h:271:14: 'cstdint' file not found /usr/local/include/opencv2/hal/defs.h:271:14: 找不到“cstdint”文件

Hope someone could help me希望有人可以帮助我

based on the top answer in this question , there are two ways to fix this problem regarding to this fact that you are using of macOs and your default compiler is Clang.基于这个问题的最佳答案,有两种方法可以解决这个问题,因为您使用的是 macO,并且您的默认编译器是 Clang。 You can use:您可以使用:

#include <tr1/cstdint>

or或者

#include <stdint.h>

instead of cstdint, that is a part of libc++.而不是 cstdint,它是 libc++ 的一部分。

I hit this when trying to import a header (.h) that was written for C++ into some Objective C code (.m).我在尝试将为 C++ 编写的头文件 (.h) 导入某些 Objective C 代码 (.m) 时遇到了这个问题。

The solution for me was to create a middle-ground Objective C++ file (.mm) and header that that imported the C++ header and then exported c-compatible wrapper functions.我的解决方案是创建一个中间目标 C++ 文件 (.mm) 和头文件,该文件导入 C++ 头文件,然后导出与 c 兼容的包装函数。

The header had something like this in it to make it play nice with Objective-C (.m) code标题中有这样的东西,使它与 Objective-C (.m) 代码一起玩

#if defined(__cplusplus)
extern "C" {
#endif

const char *MyNewFunction(void); // or whatever

#if defined(__cplusplus)
}
#endif

(Credit to Dave Hylands for helping me figure all of that out.) (感谢Dave Hylands帮助我解决了所有这些问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM