c++ - 安装多个版本时使用特定的 protobuf 版本

标签 c++ protocol-buffers ubuntu-18.04 gazebo-simu px4

我正在尝试编译 PX4 提供的凉亭示例, 根据 PX4's instructions .我正在开发 Ubuntu-18.04。
运行命令时:make px4_sitl gazebo ,出现以下错误:

...
In file included from Range.pb.h:27:0,
                 from Range.pb.cc:5:
/usr/include/gazebo-9/gazebo/msgs/quaternion.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
/usr/include/gazebo-9/gazebo/msgs/quaternion.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
/usr/include/gazebo-9/gazebo/msgs/quaternion.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
...
将错误消息拼凑在一起给出:此文件是由与您的 Protocol Buffer header 不兼容的较新版本的 protoc 生成的。请更新您的标题。
我有两个不同的protoc我机器上的二进制文件:
  • /usr/bin/protoc (3.0.0),所需的最低版本
  • ~/catkin_ws/devel/bin/protoc (2.6.0),太老了,默认使用

  • 如何确保使用第一个版本?我试过这个:export PATH=/usr/bin:$PATH确保首先找到正确的编译器,但我可能还需要指出使用正确的头文件,因此 /usr/include/google/protobuf 中的头文件而不是 ~/catkin_ws/devel/include/google/protobuf .但是,我不确定如何进行。

    最佳答案

    好的,所以简单地使坏路径无效(修改它)强制 make使用正确的编译器版本,因为它再也找不到错误的版本了。
    奇怪的是,将正确版本的路径放在 PATH 中。变量似乎没有任何影响。

    关于c++ - 安装多个版本时使用特定的 protobuf 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63199225/

    相关文章:

    c++ - GMock : error: cannot convert ‘cv::MatExpr’ to ‘bool’ in return

    protocol-buffers - 将 Protobuf 定义转换为 Thrift

    java - 如何最好地指定用于 Netty 的 Protobuf(最好使用内置的 protobuf 支持)

    docker - 从docker启动docker-无法连接到守护进程

    c++ - 如何将 libproxy-dev 链接到现有的 cmake 项目(C++)?

    c++ - 类不是类型

    c++ - 如何让 gcc 或 ld 报告 undefined symbol 但不失败?

    c++ - 在 nullptr 上使用重载/替换的 delete[]

    java - 无效 Protocol Buffer 异常 : Protocol message end-group tag did not match expected tag

    c - 在 Ubuntu 18.04 上编译 Python 3.7.4 时测试失败