【问题标题】:Use specific protobuf version when multiple versions are installed安装多个版本时使用特定的 protobuf 版本
【发布时间】:2020-07-31 21:20:52
【问题描述】:

我正在尝试根据PX4's instructions 编译PX4 提供的凉亭示例。我正在开发 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.
  ^~~~~
...

将错误消息重新拼凑在一起会得到:此文件是由新版本的 protoc 生成的,它与您的 Protocol Buffer 标头不兼容。请更新您的标题。

我的机器上有两个不同的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 中的头文件。但是,我不确定如何进行。

【问题讨论】:

  • 您可以尝试更改版本。您所要做的就是从 PATH 中删除上面的 /usr/include/google/protobuf 并将其替换为提供的那个。

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


【解决方案1】:

好的,所以简单地使坏路径无效(修改它)强制make 使用正确的编译器版本,因为它再也找不到错误的版本。

奇怪的是,将正确版本的路径放在PATH 变量中似乎没有任何效果。

【讨论】:

    猜你喜欢
    • 2020-02-24
    • 2011-04-19
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 2013-04-06
    相关资源
    最近更新 更多