Issue Compiling Cardano Node and CLI

There doesn’t seem to be as many people monitoring IOG Technical Community Discord these days…So I’ll bring the question here in hopes of a fix.

Hey guys, I’m running into an issue with compiling.

Failed to build cardano-crypto-class-2.1.4.0. The failure occurred during the configure step. Build log ( /root/.cabal/logs/ghc-8.10.7/cardano-crypto-class-2.1.4.0-57ff6d5dac9e424486497c239c0282176e030208ae85190337ff0ffefa3a86af.log ): Configuring library for cardano-crypto-class-2.1.4.0… Error: cabal-3.8.1.0: Missing dependency on a foreign library:

  • Missing (or bad) C library: blst

I’ve downloaded and installed the blst library as per the Coin Cashew guide. This is a new relay I am setting up.

Thanks in advance,
Michael Phillips (Vivid)

In case you dont find the answer here aswell, you might want to ask here : Telegram: Contact @CardanoStakePoolWorkgroup

this is probably the most active channel for such questions.

Highly surprised. Used to have a response in 10 minutes with any of these routes. 24 hours later, nothing.

You are missing the blst library.

Follow the instructions at: cardano-node-wiki/docs/getting-started/install.md at main · input-output-hk/cardano-node-wiki · GitHub

Those IOG instructions explain how to build and install the IOG specified versions of sodium, secp256k1, and blst libraries before you build cardano-node.

Alternatively, if you are keen to build the dependent libraries and cardano-node into deb packages for easy install using your package manager onto any Debian/Ubuntu system without needing to customise you ld_library_path and binary path or needing to manually copy libraries and binaries around, then you can follow my instructions here: GitHub - TerminadaPool/cardano-node-debian

I don’t know why everyone in Cardano land seems to prefer installing the entire build chain onto every machine they intend to run cardano-node, and to manually build everything on every relay machine. Or why they want to manually copy files around in an error prone way and remove/overwrite the old versions when they upgrade. Or why they want to customise their ld_library_path and bin path and install everything Cardano related in non-standard locations. Most people running Linux prefer to use a package manager for every other piece of software on their system. Anyway… Whatever.

I used CoinCashew’s guide, as usual, to install libsecp256k1 and blst. Which is why I find it weird that I’m having an issue. Installing the Glasgow Haskell Compiler and Cabal | English | CoinCashew

I’ll give your instructions a go and see what I come up with. Thanks.

Looks like I’m running into an issue with your instructions, as well.

make[1]: Entering directory '/home/builder/src/libblst-iog/libblst-iog-0.3.11'
echo "CFLAGS=-g -O2 -ffile-prefix-map=/home/builder/src/libblst-iog/libblst-iog-0.3.11=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -fno-builtin -fPIC -Wextra -Werror"
CFLAGS=-g -O2 -ffile-prefix-map=/home/builder/src/libblst-iog/libblst-iog-0.3.11=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -fno-builtin -fPIC -Wextra -Werror
./build.sh
+ cc -g -O2 -ffile-prefix-map=/home/builder/src/libblst-iog/libblst-iog-0.3.11=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -fno-builtin -fPIC -Wextra -Werror -c ./src/server.c
clang: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]
clang: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]
make[1]: *** [debian/rules:16: override_dh_auto_build] Error 1
make[1]: Leaving directory '/home/builder/src/libblst-iog/libblst-iog-0.3.11'
make: *** [debian/rules:12: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -b failed

I have never seen that optimization flag is not supported error. Are you running an up to date Debian stable system?

lsb_release -a

No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

This my /etc/apt/sources.list file:

deb Index of /debian bookworm main non-free-firmware
deb Index of /debian-security bookworm-security main non-free-firmware
deb Index of /debian bookworm-updates main non-free-firmware

cc --version

Debian clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

I just created a new Debian 12 (bookworm) kvm virtual machine with only the base install packages. Then I followed the instructions at: GitHub - TerminadaPool/libblst-iog-debian

The only error I see is the lintian error at the end (which doesn’t matter):

E: libblst-iog: no-copyright-file

The libblst deb package is built properly:

sha256sum ../libblst-iog_0.3.11_amd64.deb

ccd9e0dc6f202287c741603654466446a43ecc74bfe652fe831d6d0830647eb3 …/libblst-iog_0.3.11_amd64.deb

I’m running Ubuntu.

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Did you install libssl.so.1.1 manually? 22.04 doesn’t include it

wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

That is a nuisance. The Ubuntu version of clang 14.0.0 doesn’t support one of the default flags configured automatically by the debian build system. You would think that Ubuntu would be very similar to Debian since it is based off it, but alas Debian stable has clang 14.0.6. clang/llvm is not necessary, it just seemed like a good idea because I think using it might produce slightly more optimised binaries.

OK. You inspired me to go install a Ubuntu virtual machine and work through my instructions step by step. My systems all run Debian stable. I haven’t ever used Ubuntu, so this is a learning experience for me. I followed these instructions for how to install a Ubuntu vm: How to Install Ubuntu 22.04 Virtual Machine on KVM

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy

I couldn’t be bothered to figure out how to disable just that one particular clang/llvm compiler option that debuild is setting somewhere, so I elected to simply not use clang/llvm at all and instead use the default gcc and g++ compilers. In other words, you can simply skip that step about installing clang/llvm, and if you have already done it, then you can revert the changes with:

sudo update-alternatives --remove-all cc; \
sudo update-alternatives --remove-all c++

Then uninstall (apt purge) clang/llvm if you like.

I followed my instructions for each dependency library (skipping the clang/llvm option):

sha256sum libblst-iog_0.3.11_amd64.deb

7fe0a72adc3730e50938bcd0d33b6d2c1cce5c65a5eb1e2202edea2fda082518 libblst-iog_0.3.11_amd64.deb

sha256sum libsodium{23,-dev}-iog_1.0.18_amd64.deb

32f04f8d2cdc820acaef827e42a165c532e34ac7ec280085247c6683c41b2d14 libsodium23-iog_1.0.18_amd64.deb
c3a03bfd420296d2b1291ac969537d99da9b35b8d8ed79219eef84387a332475 libsodium-dev-iog_1.0.18_amd64.deb

sha256sum libsecp256k1-{2,dev}-iog_0.3.2_amd64.deb

57ffde970b87ed157a74b814588baa382dd48e1cb52e1ee4a34145ab61f33a90 libsecp256k1-2-iog_0.3.2_amd64.deb
6ff4d6cee6b154104dfa95a35dc30ef6f4e610ce8f9f3228d84bee35357a7e4d libsecp256k1-dev-iog_0.3.2_amd64.deb

Then I installed all the libraries as root:

sudo dpkg -i /home/builder/src/libblst-iog/libblst-iog_0.3.11_amd64.deb; \
sudo dpkg -i /home/builder/src/libsodium-iog/libsodium{23,-dev}-iog_1.0.18_amd64.deb; \
sudo dpkg -i /home/builder/src/libsecp256k1-iog/libsecp256k1-{2,dev}-iog_0.3.2_amd64.deb

Then I noted @jeremyisme 's advice about Ubuntu and libssl1.1, but I think this might be a newer security updated version of that library:

wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb; \
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb

Then I followed my instructions at GitHub - TerminadaPool/cardano-node-debian (skipping the clang/llvm option).

sha256sum cardano-{cli,node}_8.9.1_amd64.deb

9382cd4f24a43c4ec1979322c5197f0bcf806f33220c61e0b2f18641231f3039 cardano-cli_8.9.1_amd64.deb
12eff8cef25e8356bb7ae65845b5083a9677a8f6f535752f6c0fa004d606468b cardano-node_8.9.1_amd64.deb

Then I installed the cardano-node and cardano-cli packages:

sudo dpkg -i /home/builder/src/cardano-node/cardano-{cli,node}_8.9.1_amd64.deb; \

cardano-cli --version; \
cardano-node --version

cardano-cli 8.20.3.0 - linux-x86_64 - ghc-9.8
git rev da945ea983d4722a9ffe54250edba9a193a57cf0
cardano-node 8.9.1 - linux-x86_64 - ghc-9.8
git rev da945ea983d4722a9ffe54250edba9a193a57cf0

I will add a note to my instructions for Ubuntu users to avoid using clang/llvm and also that they need to manually install libssl1.1

Now I run into the same blst issue. So confused by this. Followed your instructions exactly.

Failed to build cardano-crypto-class-2.1.4.0. The failure occurred during the
configure step.
Build log (
/root/.cabal/logs/ghc-9.8.2/cardano-crypto-class-2.1.4.0-5c91bbae7bcf6960f073cb2405cdd1870c70dedfdfc1bc5ad172429e1e9b8c06.log
):
Configuring library for cardano-crypto-class-2.1.4.0..
Error: cabal-3.10.2.1: Missing dependency on a foreign library:
* Missing (or bad) C library: blst
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

Error: cabal: Failed to build cardano-crypto-class-2.1.4.0 (which is required
by exe:cardano-node from cardano-node-8.9.1). See the build log above for
details.

make[1]: *** [debian/rules:57: override_dh_auto_build] Error 1
make[1]: Leaving directory '/root/src/cardano-node/cardano-node-8.9.1'
make: *** [debian/rules:12: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -b failed```

The error indicates that you are missing the blst library. Did you install the libblst-iog package that you built to your build machine?

You can check the contents of a deb package with this command:

dpkg -c ~/src/libblst-iog/libblst-iog_0.3.11_amd64.ded

-rw-r–r-- root/root 23220 2024-03-28 16:53 ./usr/include/blst.h
-rw-r–r-- root/root 38831 2024-03-28 16:53 ./usr/include/blst.hpp
-rw-r–r-- root/root 4706 2024-03-28 16:53 ./usr/include/blst_aux.h

-rw-r–r-- root/root 298102 2024-03-28 16:53 ./usr/lib/x86_64-linux-gnu/libblst.a
drwxr-xr-x root/root 0 2024-03-28 16:53 ./usr/lib/x86_64-linux-gnu/pkgconfig/
-rw-r–r-- root/root 273 2024-03-28 16:53 ./usr/lib/x86_64-linux-gnu/pkgconfig/libblst.pc

Now check that those files are installed to your build machine:

ls -al /usr/include/blst.h; \
ls -al /usr/lib/x86_64-linux-gnu/libblst.a;

-rw-r–r-- 1 root root 23220 Mar 28 16:53 /usr/include/blst.h
-rw-r–r-- 1 root root 298102 Mar 28 16:53 /usr/lib/x86_64-linux-gnu/libblst.a

If you didn’t install the iog specified dependency libraries then ensure you followed this step: