C++进行protobuf编译时遇到错误“无法解析的外部符号”(LNK2019)

详细的报错内容:

1>gzip_stream.obj : error LNK2019: 无法解析的外部符号 deflate,函数 "private: int __cdecl google::protobuf::io::GzipOutputStream::Deflate(int)" (?Deflate@GzipOutputStream@io@protobuf@google@@AEAAHH@Z) 中引用了该符号
1>gzip_stream.obj : error LNK2019: 无法解析的外部符号 deflateEnd,函数 "public: bool __cdecl google::protobuf::io::GzipOutputStream::Close(void)" (?Close@GzipOutputStream@io@protobuf@google@@QEAA_NXZ) 中引用了该符号
1>gzip_stream.obj : error LNK2019: 无法解析的外部符号 inflate,函数 "private: int __cdecl google::protobuf::io::GzipInputStream::Inflate(int)" (?Inflate@GzipInputStream@io@protobuf@google@@AEAAHH@Z) 中引用了该符号
1>gzip_stream.obj : error LNK2019: 无法解析的外部符号 inflateEnd,函数 "public: virtual __cdecl google::protobuf::io::GzipInputStream::~GzipInputStream(void)" (??1GzipInputStream@io@protobuf@google@@UEAA@XZ) 中引用了该符号
1>gzip_stream.obj : error LNK2019: 无法解析的外部符号 deflateInit2_,函数 "private: void __cdecl google::protobuf::io::GzipOutputStream::Init(class google::protobuf::io::ZeroCopyOutputStream *,struct google::protobuf::io::GzipOutputStream::Options const &)" (?Init@GzipOutputStream@io@protobuf@google@@AEAAXPEAVZeroCopyOutputStream@234@AEBUOptions@1234@@Z) 中引用了该符号
1>gzip_stream.obj : error LNK2019: 无法解析的外部符号 inflateInit2_,函数 "int __cdecl google::protobuf::io::internalInflateInit2(struct z_stream_s *,enum google::protobuf::io::GzipInputStream::Format)" (?internalInflateInit2@io@protobuf@google@@YAHPEAUz_stream_s@@W4Format@GzipInputStream@123@@Z) 中引用了该符号
1>C:\▇▇▇▇▇\libz.a : warning LNK4272: 库计算机类型“x86”与目标计算机类型“x64”冲突
1>▇▇▇▇▇\protoc\build\Debug\libprotobufd.dll : fatal error LNK1120: 6 个无法解析的外部命令

也有报库文件(libz.a)计算机类型不符的问题,不知道有没有影响,最后查了一下这些函数定义都在 zlib.h,俺寻思应该是zlib的库没有链接到,网上下了一套 zlib 源码(zlib官网),就看到这里报错的 inflate 和 deflate 在源码里都有,所以就直接在报错工程里加入了 zlib 的这几个源码,报错的内容变成新加入的源码,干脆一口气把 zlib 文件夹下面的源码全部拉进来,编译就通过了。途中参考的其它文章如下。虽然我不是这样的问题,但说不定有人需要

error LNK2019 无法解析的外部符号 deflatehttps://blog.csdn.net/hfdgjhv/article/details/84099987

【Protobuf】报错 LNK2019 无法解析的外部符号解决方法https://blog.csdn.net/qq_42067550/article/details/126484185

 下面的这个参考文章当时找错了,但是成功编译之后在其他工程引用是需要进行这篇文章中提到的操作。
c++编译protobuf时提示LNK2001 无法解析的外部符号https://blog.csdn.net/alvinlyb/article/details/110952210

 【补充】(2022.11.10)在cmake设定阶段可以选择不使用zlib支持编译,就不会报zlib的错了。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值