编译grpc route_guide example的时候遇到#error This file was generated by an old version of protoc

编译grpc route_guide example的时候遇到#error This file was generated by an old version of protoc

  • 原因:

    • 系统中有两个protoc版本(之前下载了protobuf的git,当时编译安装了一遍。然后下grpc的git,在编译的时候按照教程使用“cmake -DgRPC_INSTALL=ON …”之后make install又安装了一遍。)
  • 解决:

    • 方法一:
      卸载之前git 安装的protobuf:进入该目录,执行make uninstall

    • 方法二:

    1. 把route_guide example 中的Makefile的protoc版本改成protoc-3.13.0.0(也就是安装grpc的时候的protoc版本)
    2. 然后mount --bind /home/xxx/.local/lib/pkgconfig/protobuf.pc /usr/lib/pkgconfig/protobuf.pc(由于在生成可执行文件的时候用了pkg-config --libs protobuf, 而系统中pkg-config的 PKG_CONFIG_PATH是/usr/lib/x86_64-linux-gnu,版本号就不对,应该使用/home/xxx/.local/lib/pkgconfig/protobuf.pc)
  • PS:

    • 为了方便直接用了mount命令,也许可以在cmake中直接加入SET(ENV{PKG_CONFIG_PATH} /home/xxx/.local/lib/pkgconfig) 或者在Makefile中加入export PKG_CONFIG_PATH :=/home/xxx/.local/lib/pkgconfig
    • 有点疑问是系统中PKG_CONFIG_PATH是/usr/lib/x86_64-linux-gnu,而protobuf.pc是在/usr/lib/pkgconfig底下,这个是怎么找到的?–解决:pkg-config --variable pc_path pkg-config可以查看pkg-config的查找路径,而/usr/lib/pkgconfig包含在路径中
    • 在make install的时候最好记录一下,方便后续删除(make install 2>&1 | tee makeinstall.log)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值