【问题标题】:Build Proxygen under Ubuntu 16.04在 Ubuntu 16.04 下构建 Proxygen
【发布时间】:2016-08-06 16:33:39
【问题描述】:

我想使用 Ubuntu 16.04 从 github 构建 Facebook 的 Proxygen c++ http 库。这是我设置的环境以及 deps.sh 命令安装依赖项:

gcc --version
  gcc (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609
export CPPFLAGS="-std=c++14"
export CXXFLAGS="-std=c++14"
git clone git@github.com:facebook/proxygen.git
cd proxygen/proxygen && ./deps.sh

这让我完成了构建其愚蠢依赖的大部分工作,但我收到了一个不完整的类型错误:

libtool: compile:  g++ -DHAVE_CONFIG_H -I./.. -pthread -I/usr/include -std=c++14 -std=gnu++1y -std=c++14 -MT io/async/AsyncPipe.lo -MD -MP -MF io/async/.deps/AsyncPipe.Tpo -c io/async/AsyncPipe.cpp  -fPIC -DPIC -o io/async/.libs/AsyncPipe.o
In file included from /usr/include/c++/5/bits/move.h:57:0,
                 from /usr/include/c++/5/bits/stl_pair.h:59,
                 from /usr/include/c++/5/utility:70,
                 from /usr/include/c++/5/algorithm:60,
                 from ./../folly/Conv.h:26,
                 from Conv.cpp:16:
/usr/include/c++/5/type_traits: In instantiation of ‘struct std::make_unsigned<__int128>’:
Conv.cpp:528:52:   required from ‘folly::detail::ConversionResult<T> folly::detail::digits_to(const char*, const char*) [with Tgt = __int128]’
Conv.cpp:658:16:   required from here
/usr/include/c++/5/type_traits:1757:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128, false, false>’
     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
                                                              ^
/usr/include/c++/5/type_traits:1721:11: note: declaration of ‘class std::__make_unsigned_selector<__int128, false, false>’
     class __make_unsigned_selector;
           ^
/usr/include/c++/5/type_traits: In instantiation of ‘struct std::make_unsigned<__int128 unsigned>’:
Conv.cpp:528:52:   required from ‘folly::detail::ConversionResult<T> folly::detail::digits_to(const char*, const char*) [with Tgt = __int128 unsigned]’
Conv.cpp:661:16:   required from here

有没有人尝试或解决过这个问题?我还不熟悉代码库。蒂亚。

【问题讨论】:

  • 仅供参考,Ubuntu 16.04 引入的 boost 版本是 1.58.0。
  • 您的编译器选项现在看起来像“-std=c++14 -std=gnu++1y -std=c++14”。如果你尝试编译这样的代码:#include int main () { auto a = std::make_unsigned<__int128> (); } 你会失败,因为编译选项。只需删除 CPPFLAGS、CXXFLAGS。
  • 谢谢@vadikrobot。我没有设置 [gnu++1y],这就是我尝试 c++14 的原因。

标签: c++ c++14 ubuntu-16.04 gcc5 proxygen


【解决方案1】:

TL;DR Proxygen 需要 GNU 扩展;使用-std=gnu++11-std=gnu++14


为什么在构建 proxygen 及其依赖项时需要覆盖 C++ 标准? Folly 本身指定-std=gnu++1y。如果你删除

export CPPFLAGS="-std=c++14"
export CXXFLAGS="-std=c++14"

并尝试构建它,它几乎会,我必须做出愚蠢的唯一更改是fix membarrier

如果你坚持使用-std=c++14,那么问题其实不在于愚蠢,而在于libstdc++对GNU扩展的处理,这个简单的一行:

typedef std::make_unsigned<__int128>::type int128_type;

使用-std=gnu++11-std=gnu++1y 可以轻松编译,但使用-std=c++11-std=c++14 中的任何一个都会失败。而且很难说它是一个错误(因为编译器提供了__int128 类型(并且愚蠢地在其配置脚本中检测到,顺便说一句)但C++ 库有问题)还是一个功能(因为__int128 是一个首先是扩展,并且应该使用一些标准的 GNU 变体来正确获取它)。

【讨论】:

  • 这正是我一直在寻找的,您节省了我回溯到发现 GNU 扩展的时间。也感谢愚蠢的补丁。
  • 现在实际编译...没有 CPPFLAGS,使用 gcc 5.4.0,我得到“检查 g++ 是否支持 -std=gnu++1y 的 C++1y 功能...否 - 配置: 错误: 在 g++ 中找不到 cxx1y 支持”。我添加了对 gnu++14 的支持,我们走了。
  • 最终结果:构建没有错误,所有测试都通过了。谢谢罗曼。仅供参考,我不需要愚蠢的补丁。
  • Roman,一旦我进入安装步骤,我发现我确实需要你的内存补丁。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-23
  • 1970-01-01
  • 2018-09-24
  • 2018-05-18
相关资源
最近更新 更多