无法在 Ubuntu 上构建 protobuf 2.4.1
Unable to build protobuf 2.4.1 on Ubuntu
当我尝试 运行 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:
有人知道怎么解决吗?
三件事spring要注意:
您可能需要指定给定的 C++ 版本,例如-std=c++11
看来您也可以在 Ubuntu 20 上安装多个版本的 gcc:https://linuxize.com/post/how-to-install-gcc-on-ubuntu-20-04/
如果一切都失败了,您可以创建一个 docker 图像来执行您的编译,将 docker 图像基于旧版本的 Ubuntu/Debian and/or 使用较旧的编译器。另请参阅:https://askubuntu.com/questions/1229774/how-to-use-an-older-version-of-gcc
当我尝试 运行 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:
有人知道怎么解决吗?
三件事spring要注意:
您可能需要指定给定的 C++ 版本,例如
-std=c++11
看来您也可以在 Ubuntu 20 上安装多个版本的 gcc:https://linuxize.com/post/how-to-install-gcc-on-ubuntu-20-04/
如果一切都失败了,您可以创建一个 docker 图像来执行您的编译,将 docker 图像基于旧版本的 Ubuntu/Debian and/or 使用较旧的编译器。另请参阅:https://askubuntu.com/questions/1229774/how-to-use-an-older-version-of-gcc