当我试图运行make
命令在Ubuntu 20上构建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:
有人知道怎么修吗?
2条答案
按热度按时间nbysray51#
我想到三件事:
1.您可能需要指定一个给定的C++版本,例如
-std=c++11
1.你也可以在Ubuntu 20上安装多个版本的gcc:https://linuxize.com/post/how-to-install-gcc-on-ubuntu-20-04/
1.如果其他方法都失败了,你可以创建一个docker镜像来执行编译,基于Ubuntu/Debian的旧版本和/或使用旧版本的编译器。请看这个:https://askubuntu.com/questions/1229774/how-to-use-an-older-version-of-gcc
zzzyeukh2#
在Ubuntu 20上安装gcc 5.3.1允许我使用
make
和install
协议2.4.1。Xenial存储库仍然提供旧版本的gcc。要添加它们,请执行以下操作:
添加以下行:
安装gcc5
将默认gcc更改为5
This post was really helpful with the gcc 5 installation and provided the steps above
在安装了gcc 5之后,我可以编译并安装protoc 2.4.1:
我确实需要让protoc知道在哪里寻找共享库