简体   繁体   English

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

[英]Missing C++ std library methods and other errors while compiling EOS on Ubuntu 14.04?

I'm trying to compile the EOS blockchain/smart contract project on GitHub on Ubuntu 14.04: 我正在尝试在Ubuntu 14.04上的GitHub上编译EOS区块链/智能合约项目:

https://github.com/EOSIO/eos https://github.com/EOSIO/eos

After getting Clang 4.0 to install, installing build_essentials , and upgrading CMake to 3.5, I was able to run the build process without any missing dependencies. 在安装Clang 4.0 ,安装build_essentials并将CMake升级到3.5之后,我能够运行构建过程而不会遗漏任何依赖项。 However, now I get the errors shown below when I build the EOS source. 但是,现在我在构建EOS源时遇到下面显示的错误。 This seems to me like another general issue with the configuration of the tools on my system since many people are able to compile the EOS code, although usually on Ubuntu 14.04. 这似乎是我在系统上配置工具的另一个普遍问题,因为很多人都能够编译EOS代码,尽管通常在Ubuntu 14.04上。

Can anyone tell by looking at the errors I'm getting what tool or library I need to install or upgrade? 任何人都可以通过查看错误来判断我正在获得需要安装或升级的工具或库吗?

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));
                                  ^~~~~~~~~~~~~~~~~~~

The Missing _t alias names look like you're having issues with C++14. Missing _t别名看起来像是在遇到C ++ 14的问题。 The header paths in the error messages look like you're using the standard library from GCC 4.8 (the default compiler on Ubuntu 14.04), which is simply too old. 错误消息中的标头路径看起来就像是使用了GCC 4.8(Ubuntu 14.04上的默认编译器)的标准库,这个库太旧了。

I can see two solutions: 我可以看到两个解决方案:

Switch from GCC's libstdc++ to an up-to-date version of LLVM's libc++ . 从GCC的libstdc ++切换到LLVM的libc ++的最新版本。 I'm not familiar enough with Ubuntu to tell you how to install it. 我对Ubuntu不太熟悉,告诉你如何安装它。 For the compilation of EOSIO you must pass the -stdlib=libc++ option to Clang to switch to the different stdlib. 要编译EOSIO,必须将-stdlib=libc++选项传递给Clang以切换到不同的stdlib。 EOSIO looks like it's using CMake, so you have to include -DCMAKE_CXX_FLAGS=-stdlib=libc++ in your CMake command line. EOSIO看起来像是在使用CMake,因此您必须在CMake命令行中包含-DCMAKE_CXX_FLAGS=-stdlib=libc++

Use the Toolchain test builds PPA to install a newer GCC and and libstdc++ in addition to your system's default one. 除了系统的默认GCC和libstdc ++之外, 使用工具链测试构建PPA来安装更新的GCC和libstdc ++ For Ubuntu 14.04 GCC 7.2.0 is the latest version available, which is perfectly C++14 capable. 对于Ubuntu 14.04,GCC 7.2.0是最新版本,完全支持C ++ 14。 Add the PPA to your package sources and then do a: 将PPA添加到您的包源,然后执行以下操作:

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

This installs both the GCC C compiler and C++ compiler along with the stdlib. 这将安装GCC C编译器和C ++编译器以及stdlib。 Your default compiler is still going to be the old GCC 4.8, so you'll have to tell CMake about the newer versions: 您的默认编译器仍然是旧的GCC 4.8,因此您必须告诉CMake有关较新版本的信息:

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

Note that now you compile EOSIO with GCC (and the new stdlib) instead of Clang. 请注意,现在您使用GCC(和新的stdlib)而不是Clang编译EOSIO。 Instructing Clang to use a specific version of libstdc++ should be possible, but I don't know how. 指示Clang使用特定版本的libstdc ++应该是可能的,但我不知道如何。

Official support is for Ubuntu 16.10. 官方支持是Ubuntu 16.10。 Consider upgrading. 考虑升级。 (EDITED: I mistakenly said 14.10) Source: https://github.com/EOSIO/eos/wiki/Local-Environment#211-ubuntu-1610 (编辑:我错误地说14.10)来源: https//github.com/EOSIO/eos/wiki/Local-Environment#211-ubuntu-1610

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM