编译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 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
如下图所示,