Ubuntu16.04 C++调用libdarknet.so时protobuf冲突问题

environment

  • Ubuntu 16.04
  • Qt 5.12.6
  • OpenCV 3.2.0

Problem

[libprotobuf FATAL google/protobuf/stubs/common.cc:79] This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.4.0). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in “/build/mir-O8_xaj/mir-0.26.3+16.04.20170605/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc”.)
terminate called after throwing an instance of ‘google::protobuf::FatalException’
what(): This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.4.0). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in “/build/mir-O8_xaj/mir-0.26.3+16.04.20170605/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc”.)

analysis

  1. 问题出现:在原有c++工程中添加调用libdarknet.so库文件的模块后出现error。原project的proto版本是3.4.0,不知道从哪冒出来个天使2.6.1版本与之冲突了。
  2. 网查答案都在说是/opt/Qt/5.9/gcc_64/plugins/platformthemes的库libqgtk3.so引起的:
    Protobuf version conflicts with Qt
    这些方法都试了,没用。
  3. 经历痛苦排查发现,如果在是编译生成libdarknet.so库的时候,在Makefile中启用OPENCV=1,就会导致这个问题的出现。
  4. 猜想应该是OpenCV 3.2.0编译安装过程中,依赖proto的低版本,导致再去使用OpenCV 3.2.0编译darknet时,libdarknet.so依赖于proto的低版本。
  5. 尝试重装OpenCV。

Solution

  1. 安装选择OpenCV 3.4.5版本,没有啥特别原因,就是正好电脑里有下好的。可参考(ubuntu16.04编译安装opencv3.4.5
  2. 在安装过程中,通过cmake-gui配置,取消下列3个变量的勾选:

WITH_GTK
WITH_PROTOBUF
BUILD_PROTOBUF

  1. 安装成功后,重新编译生成libdarknet.so,问题解决!
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值