Darknet编译报错: cvdef.h:485:1: error: unknown type name ‘namespace’

本文解决Darknet在OpenCV环境下编译时出现的cvdef.h错误,通过注释特定代码修复类型定义冲突,确保Darknet与OpenCV兼容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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);

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值