【问题标题】:Installing Iroha on Raspberry pi 4在树莓派 4 上安装 Iroha
【发布时间】:2021-01-23 13:26:36
【问题描述】:

我正在尝试在 Raspberry pi 3 和 4 上安装 Iroha。我正在手动构建它,如下所示:

1) git clone -b master https://github.com/hyperledger/iroha

  1. cd iroha

  2. mkdir 构建;光盘构建; cmake ..; make -j$(nproc)

然后我得到以下错误

cmake/dependencies.cmake:24 (find_package) 处的 CMake 错误: 找不到“spdlog”提供的包配置文件(请求 版本 1.3.1) 具有以下任何名称:

spdlogConfig.cmake spdlog-config.cmake

将“spdlog”的安装前缀添加到CMAKE_PREFIX_PATH或设置 “spdlog_DIR”到包含上述文件之一的目录。如果“spdlog” 提供单独的开发包或SDK,请确保已 安装。 调用堆栈(最近的调用优先): CMakeLists.txt:179(包括)

– 配置不完整,出现错误! 另请参阅“/home/pi/Desktop/iroha/build/CMakeFiles/CMakeOutput.log”。 另见“/home/pi/Desktop/iroha/build/CMakeFiles/CMakeError.log”

知道如何解决这个问题吗?

【问题讨论】:

    标签: raspberry-pi4 hyperledger-iroha


    【解决方案1】:

    我已经设法在Ubuntu Server 20.04.1 LTS (GNU/Linux 5.4.0-1015-raspi aarch64) 上的 RPI 4 上构建了 iroha(版本 1.1.3)

    首先我们需要更新我们的系统:

    sudo apt-get update
    sudo apt-get upgrade -y
    

    那我们应该根据instruction安装依赖:

    sudo apt-get -y --no-install-recommends install build-essential git ca-certificates tar curl unzip cmake vim ninja-build -y
    

    现在我建议重启系统:

     sudo reboot now
    

    下一步是下载 iroha 源,我已经在 Iroha 1.1.3 上测试过,所以我的源是:

    git clone --branch 1.1.3 https://github.com/hyperledger/iroha.git --depth=1
    

    根据instruction下一步是调用:

    iroha/vcpkg/build_iroha_deps.sh
    

    但是当我在 2020 年 10 月使用脚本构建时,一些额外的步骤是必要的,这是因为以下事实:

    1. vcpkg 不支持 aarch64,
    2. RPI 上的 g++ 没有标志 -m64
    3. VCPKG 下载的依赖项 (GRPC) 之一未编译

    当您在一段时间后构建它时,您可能不会遇到任何这些问题,但您也可能会遇到不同的问题。

    所以在 RPI 上构建的第一步就是运行命令:

    iroha/vcpkg/build_iroha_deps.sh
    

    然后等待。如果您没有发现任何问题,则不需要该说明。

    如果您看到cmake 与vcpkg 连接的问题,则表示vcpkg 仍然不支持aarch64,但是有一个hack 可以使用系统的cmake,而不是通过vcpkg 下载。为此,我们需要在命令bootstrap-vcpkg.sh 之后将-useSystemBinaries 添加到文件iroha/vcpkg/build_iroha_deps.sh。可以通过命令快速完成:

    sed -i 's/\(^.*bootstrap.*$\)/\1 -useSystemBinaries/g' iroha/vcpkg/build_iroha_deps.sh
    

    然后您可以继续构建:

    ./vcpkg/vcpkg install $(cat iroha/vcpkg/VCPKG_DEPS_LIST | cut -d':' -f1 | tr '\n' ' ')
    ./vcpkg/vcpkg install --head $(cat iroha/vcpkg/VCPKG_HEAD_DEPS_LIST | cut -d':' -f1 | tr '\n' ' ')
    

    如果您在构建boost-container 时遇到问题,与标志-m64 连接,在 RPI 的 gcc 上不存在,您需要创建包装器来删除标志。我在 C++ 中创建了包装器(文件g++wrapper.cc):

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <string>
    using namespace std;
    
    
    string args2Text(int argc, char** argv, const char* forbiddenFlag="-m64", const char* compilerCommand="/usr/bin/g++");
    
    int returnValidNumberFromSubcommand(int systemCallReturnValue);
    
    string escapeQuotes(const string& text);
    
    
    int main(int argc, char* argv[])
    {
        const auto command = args2Text(argc, argv);
        const auto status = system(command.c_str());
        return returnValidNumberFromSubcommand(status);
    }
    
    string args2Text(int argc, char** argv, const char* forbiddenFlag, const char* compilerCommand)
    {
        string command = compilerCommand;
        for (int i = 1; i < argc; ++i)
        {
            if (strcmp(argv[i], forbiddenFlag))
                command += " "s + escapeQuotes(argv[i]);
        }
        return command;
    }
    
    string escapeQuotes(const string& text)
    {
        constexpr const char* escapedQuote = R"_(\")_";
        string returnString;
        returnString.reserve(text.size() + 2);
        for (auto c : text)
        {
            if ('"' == c)
                returnString += escapedQuote;
            else
                returnString += c;
        }
        return returnString;
    }
    
    int returnValidNumberFromSubcommand(int systemCallReturnValue)
    {
        if (systemCallReturnValue < 0)
        {
            return -1;
        }
        else
        {
            if (WIFEXITED(systemCallReturnValue))
            {
                return WEXITSTATUS(systemCallReturnValue);
            }
            else
            {
                return 1;
            }
        }
    }
    

    只需编译:g++ g++wrapper.cc -o g++wrapper 我们只需要用我们的包装器替换系统的/usr/bin/c++,我们可以用命令来做到这一点:

    sudo mv /usr/bin/c++ /usr/bin/c++_original
    sudo mv g++wrapper /usr/bin/c++
    

    现在我们可以像上面一样恢复构建了。

    当我们遇到构建 GRPC 的问题时:

    -- Using source at /home/ubuntu/vcpkg/buildtrees/grpc/src/577f0c79b1-086c8c6e6c
    -- Configuring x64-linux-dbg
    -- Configuring x64-linux-rel
    -- Building x64-linux-dbg
    CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
        Command failed: /usr/bin/cmake;--build;.;--config;Debug;--target;install;--;-v
        Working Directory: /home/ubuntu/vcpkg/buildtrees/grpc/x64-linux-dbg
        See logs for more information:
          /home/ubuntu/vcpkg/buildtrees/grpc/install-x64-linux-dbg-out.log
    

    并检查日志文件:

    /home/ubuntu/vcpkg/buildtrees/grpc/install-x64-linux-dbg-out.log
    /home/ubuntu/vcpkg/buildtrees/grpc/src/577f0c79b1-086c8c6e6c/src/core/lib/iomgr/ev_epollex_linux.cc:1105:13: error: ambiguating new declaration of ‘long int gettid()’
    

    然后我修复了注释gettid 函数重定义:

    sed -i 's_\(^.*long gettid(.*$\)_//\1_g' $(find . -name ev_epollex_linux.cc)
    

    然后我在函数gettid的另一个定义中遇到了类似的问题,所以我做了类似的:

    sed -i 's_\(^.*long gettid(.*$\)_//\1_g' $(find . -name log_linux.cc)
    

    改正后我们可以继续构建。

    如果一切正常并且我们用二进制文件包装了 c++ 命令,我们应该恢复原始命令:

    sudo mv /usr/bin/c++_original /usr/bin/c++
    

    然后我们应该能够将依赖项编译到 iroha。现在根据指令2我们应该找出我们需要什么cmake的标志,我们可以用命令来做:

    vcpkg/vcpkg integrate install
    

    在我的情况下是打印出来的:

    -DCMAKE_TOOLCHAIN_FILE=/home/ubuntu/vcpkg/scripts/buildsystems/vcpkg.cmake
    

    现在我们可以在 cmake 的命令中使用它了。

    cd iroha
    cmake -H. -Bbuild -DTESTING=OFF \
    -DVCPKG_TARGET_TRIPLET=x64-linux \
    -DCMAKE_TOOLCHAIN_FILE=/home/ubuntu/vcpkg/scripts/buildsystems/vcpkg.cmake
    

    然后让我们调用 makefile(我建议在 RPI 上使用单线程):

    cd build
    make
    sudo make install
    

    如果成功就太好了!但是你看到问题了吗:

    CMake Error at cmake_install.cmake:78 (file):
      file INSTALL cannot find "/home/ubuntu/iroha/-lpthread": No such file or directory
    

    您需要在文件中注释该行:

    sed -i 's_\(^.*\-lpthread.*\)$_#\1_g' cmake_install.cmake
    

    然后我们可以重新运行:

    sudo make install
    

    这就是在 Raspberry Pi 4 上构建 Iroha 的全部内容,现在您可以安装(或使用 docker 映像)数据库并享受。

    【讨论】:

      猜你喜欢
      • 2021-08-26
      • 2021-04-04
      • 2021-01-18
      • 1970-01-01
      • 2019-12-04
      • 1970-01-01
      • 2020-08-21
      • 2015-12-10
      • 1970-01-01
      相关资源
      最近更新 更多