Darknet在OpenCV下编译出错填坑: cvdef.h:485:1: error: unknown type name ‘namespace’
这个是opencv的bug,需要注释两个文件的部分代码,详见知乎:https://zhuanlan.zhihu.com/p/36933700
第一步,找到:/usr/local/include/opencv2/core/cvdef.h
修改485行左右的代码:
#else
#include <stdint.h>
namespace cv {
typedef ::int8_t int8_t;
typedef ::uint8_t uint8_t;
typedef ::int16_t int16_t;
typedef ::uint16_t uint16_t;
typedef ::int32_t int32_t;
typedef ::uint32_t uint32_t;
typedef ::int64_t int64_t;
typedef ::uint64_t uint64_t;
}
#endif
把这段代码注释掉,改为:
#else
#include <stdint.h>
/namespace cv {
typedef ::int8_t int8_t;
typedef ::uint8_t uint8_t;
typedef ::int16_t int16_t;
typedef ::uint16_t uint16_t;
typedef ::int32_t int32_t;
typedef ::uint32_t uint32_t;
typedef ::int64_t int64_t;
typedef ::uint64_t uint64_t;
}/
#endif
第二步,找到:/usr/local/include/opencv2/highgui/highgui_c.h
修改139行左右的代码:
CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
修改类型为:
CVAPI(CvRect)cvGetWindowImageRect(const char* name);