error LNK2001: 无法解析的外部符号 “private: static int google::protobuf::io::CodedInputStream::default_recurs

本文解决了使用protobuf3.16.0编译ncnn时遇到的无法解析外部符号问题,通过添加预处理定义PROTOBUF_USE_DLLS到项目属性中完成修复。

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

编译ncnn的时候,用了protobuf 3.16.0, 引用Protobuf的时候,碰到这个问题,

已启动生成…
1>------ 已启动生成: 项目: caffe2ncnn, 配置: Debug x64 ------
1>caffe2ncnn.obj : error LNK2001: 无法解析的外部符号 "private: static int google::protobuf::io::CodedInputStream::default_recursion_limit_" (?default_recursion_limit_@CodedInputStream@io@protobuf@google@@0HA)
1>caffe.pb.obj : error LNK2001: 无法解析的外部符号 "class google::protobuf::internal::ExplicitlyConstructed<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > google::protobuf::internal::fixed_address_empty_string" (?fixed_address_empty_string@internal@protobuf@google@@3V?$ExplicitlyConstructed@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@123@A)
1>D:\vsNCNN\ncnn20221007\dev\tools\caffe\Debug\caffe2ncnn.exe : fatal error LNK1120: 2 个无法解析的外部命令
1>已完成生成项目“caffe2ncnn.vcxproj”的操作 - 失败。

解决办法:

在调用protobuf库的项目属性中,添加预处理定义:

PROTOBUF_USE_DLLS

如下图所示,


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值