无法在Ubuntu上构建protobuf 2.4.1

问题描述

当我尝试在Ubuntu 20上运行make命令来构建protobuf时,我遇到了这个错误

google/protobuf/compiler/command_line_interface.cc:913:55: error: cannot bind rvalue reference of type ‘std::__cxx11::basic_string<char>&&’ to lvalue of type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
  913 |       proto_path_.push_back(make_pair<string,string>(virtual_path,disk_path));
      |                                                       ^~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,from /usr/include/c++/9/bits/char_traits.h:39,from /usr/include/c++/9/string:40,from ./google/protobuf/stubs/common.h:41,from ./google/protobuf/compiler/command_line_interface.h:41,from google/protobuf/compiler/command_line_interface.cc:35:

有人知道如何解决吗?

解决方法

想到三件事:

  1. 您可能需要指定给定的C ++版本,例如-std=c++11

  2. 看来您也可以在Ubuntu 20上安装多个版本的gcc:https://linuxize.com/post/how-to-install-gcc-on-ubuntu-20-04/

  3. 如果所有其他方法均失败,则可以创建docker映像来执行编译,将docker映像基于较旧版本的Ubuntu / Debian和/或使用较旧的编译器。另请参见:https://askubuntu.com/questions/1229774/how-to-use-an-older-version-of-gcc

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...