在Ubuntu 14.04上编译EOS时缺少C ++ std库方法和其他错误?

问题描述 投票:3回答:2

我正在尝试在Ubuntu 14.04上的GitHub上编译EOS区块链/智能合约项目:

https://github.com/EOSIO/eos

在安装Clang 4.0,安装build_essentials并将CMake升级到3.5之后,我能够运行构建过程而不会遗漏任何依赖项。但是,现在我在构建EOS源时遇到下面显示的错误。这似乎是我在系统上配置工具的另一个普遍问题,因为很多人都能够编译EOS代码,尽管通常在Ubuntu 14.04上。

任何人都可以通过查看错误来判断我正在获得需要安装或升级的工具或库吗?

In file included from /usr/lib/llvm-4.0/include/clang/AST/Decl.h:31:
/usr/lib/llvm-4.0/include/llvm/Support/TrailingObjects.h:259:33: error: 'BaseTy' does not refer to a value
    static_assert(LLVM_IS_FINAL(BaseTy), "BaseTy must be final.");
                            ^
/usr/lib/llvm-4.0/include/llvm/Support/TrailingObjects.h:233:20: note: declared here
template <typename BaseTy, typename... TrailingTys>
               ^
/usr/lib/llvm-4.0/include/llvm/Support/TrailingObjects.h:259:19: error: expected expression
    static_assert(LLVM_IS_FINAL(BaseTy), "BaseTy must be final.");
              ^
/usr/lib/llvm-4.0/include/llvm/Support/type_traits.h:104:45: note: expanded from macro 'LLVM_IS_FINAL'
#define LLVM_IS_FINAL(Ty) std::is_final<Ty>()
                                        ^
Linking CXX executable codegen
/home/robert/Documents/GitHub/eos/programs/launcher/main.cpp:405:18: error: no template named 'underlying_type_t' in namespace 'std'; did you mean
      'underlying_type'?
  using T = std::underlying_type_t <enum_type>;
        ~~~~~^~~~~~~~~~~~~~~~~
             underlying_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:1855:12: note: 'underlying_type' declared here
    struct underlying_type
       ^
/home/robert/Documents/GitHub/eos/programs/launcher/main.cpp:435:17: error: no member named 'put_time' in namespace 'std'
  dstrm << std::put_time(std::localtime(&now_c), "%Y_%m_%d_%H_%M_%S");
       ~~~~~^
[ 64%] Building CXX object libraries/chain/CMakeFiles/eos_chain.dir/chain_controller.cpp.o
/home/robert/Documents/GitHub/eos/programs/launcher/main.cpp:406:39: error: no matching conversion for static_cast from 'allowed_connection' to 'T'
      (aka 'underlying_type<allowed_connection>')
  return lhs = static_cast<enum_type>(static_cast<T>(lhs) | static_cast<T>(rhs));
                                  ^~~~~~~~~~~~~~~~~~~
c++ ubuntu std eos
2个回答
4
投票

失踪的_t别名看起来像你有C ++ 14的问题。错误消息中的标头路径看起来就像是使用了GCC 4.8(Ubuntu 14.04上的默认编译器)的标准库,这个库太旧了。

我可以看到两个解决方案:

从GCC的libstdc ++切换到LLVM的libc ++的最新版本。我对Ubuntu不太熟悉,告诉你如何安装它。要编译EOSIO,必须将-stdlib=libc++选项传递给Clang以切换到不同的stdlib。 EOSIO看起来像是在使用CMake,所以你必须在你的CMake命令行中包含-DCMAKE_CXX_FLAGS=-stdlib=libc++

除了系统的默认GCC和libstdc ++外,还可以使用Toolchain test builds PPA安装更新的GCC和libstdc ++。对于Ubuntu 14.04,GCC 7.2.0是最新版本,完全支持C ++ 14。将PPA添加到您的包源,然后执行以下操作:

sudo apt-get install gcc-7 g++-7

这将安装GCC C编译器和C ++编译器以及stdlib。您的默认编译器仍然是旧的GCC 4.8,因此您必须告诉CMake有关较新版本的信息:

-DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7

请注意,现在您使用GCC(和新的stdlib)而不是Clang编译EOSIO。指示Clang使用特定版本的libstdc ++应该是可能的,但我不知道如何。


1
投票

官方支持是Ubuntu 16.10。考虑升级。 (编辑:我错误地说14.10)来源:https://github.com/EOSIO/eos/wiki/Local-Environment#211-ubuntu-1610

© www.soinside.com 2019 - 2024. All rights reserved.