Installing Iroha on Raspberry pi 4

404 views Asked by At

I am trying to install Iroha on Raspberry pi 3 and 4. I am manually building it as following:

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

  1. cd iroha

  2. mkdir build; cd build; cmake ..; make -j$(nproc)

and then i get the following error

CMake Error at cmake/dependencies.cmake:24 (find_package): Could not find a package configuration file provided by "spdlog" (requested version 1.3.1) with any of the following names:

spdlogConfig.cmake spdlog-config.cmake

Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set "spdlog_DIR" to a directory containing one of the above files. If "spdlog" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:179 (include)

– Configuring incomplete, errors occurred! See also "/home/pi/Desktop/iroha/build/CMakeFiles/CMakeOutput.log". See also "/home/pi/Desktop/iroha/build/CMakeFiles/CMakeError.log"

Any idea how to solve this?

1

There are 1 answers

0
baziorek On

I've managed to build iroha (version 1.1.3) on RPI 4 on Ubuntu Server 20.04.1 LTS (GNU/Linux 5.4.0-1015-raspi aarch64)

First of all we need to update our system:

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

Then we should install dependencies according to instruction:

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

Now I suggest to reboot system:

 sudo reboot now

Next step was to download iroha source, I've tested this on Iroha 1.1.3, so my source was:

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

Next step according to instruction is to call:

iroha/vcpkg/build_iroha_deps.sh

But when I was building with the script on October 2020 some extra steps was necessarily, it was because of facts that:

  1. vcpkg does not support aarch64,
  2. g++ on RPI does not have flag -m64
  3. one of dependency (GRPC) downloaded by VCPKG was not compiling

When You build this after some time possibly you will not face any of those problems, but it is also possible that You are going to face different problems.

So first step of building on RPI is to just run command:

iroha/vcpkg/build_iroha_deps.sh

and wait. If you don't see any problems you don't need the instruction.

If You see problem with cmake connected with vcpkg it means that vcpkg still doesn't support aarch64, but there is a hack to use system's cmake, instead of downloaded by vcpkg. To do this we need to add -useSystemBinaries to the file iroha/vcpkg/build_iroha_deps.sh after command bootstrap-vcpkg.sh. It can be done fast with command:

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

Then you can resume building:

./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' ' ')

If you face problem with building boost-container, connected with flag -m64, which does not exist on gcc at RPI, you need to create wrapper to remove the flag. I've created the wrapper in c++ (file 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;
        }
    }
}

just compile that: g++ g++wrapper.cc -o g++wrapper We just need to replace system's /usr/bin/c++ with our wrapper, we can do that with commands:

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

Now we can resume building now as above.

When we face problem with building 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

And check in the log file:

/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()’

Then I've fixed with commenting gettid function redefinition:

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

Then I've faced similar problem with another definition of function gettid, so I did similar:

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

After correcting we can resume building.

If everything is all right and we wrapped c++ command with our binary we should restore original command:

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

Then we should be able to compile dependencies to iroha. Now according to instruction2 we should find out what cmake's flag we need, we can do this with command:

vcpkg/vcpkg integrate install

in my situation it was printed:

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

Now we can use this in cmake's command.

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

Then lets call makefile (I suggest single thread on RPI):

cd build
make
sudo make install

If succesfull great! But is you see problem:

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

You need to comment that line from the file:

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

Then we can rerun:

sudo make install

Thats all about building Iroha on Raspberry Pi 4, now You can install (or use docker image) database and enjoy.