问题现象
问题一:
protobuf.internal.lock()冲突
问题二:
[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.5.1). 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”.)
环境介绍
linux mint 18.2
qt 5.9.5
protobuf 3.5.2
通过一个lib封装所有protobuf相关的操作,以及.proto文件转换生成的cxx文件。
一个app调用lib提供的功能。
错误出现在app启动阶段。
注:同样的代码在windows下并不会出现问题。
解决过程
解决问题一:
重新编译protobuf,编译前设置其参数为:
./configure --prefix=/(...)/build --disable-shared
解决问题二:
参考这篇文章:protobuf与qt的冲突
https://stackoverflow.com/questions/45703619/protobuf-version-conflicts-with-qt
另外,如果要用cmake+qt的方式构建项目,则还需要删除QT中相应的cmake模块文件:Qt5Gui_QGtk3ThemePlugin.cmake。
个人体会,cmake 对 QT的支持在3.9以后的版本才变得方便。