Bitcoin: Bitcoin Core linking error

Bitcoin Core Linking Error on Windows using WSL and Ubuntu 20.04

As a Bitcoin user, you probably know how important it is to ensure that your software is compatible with different operating systems and environments. However, building and installing Bitcoin Core, especially from source, can be a frustrating experience. In this article, we will investigate a linking error that occurred on Windows using WSL (Windows Subsystem for Linux) running Ubuntu 20.04.

Issue:

Bitcoin: Bitcoin Core linking error

When trying to build Bitcoin source code v24.2 on Windows using WSL, you may encounter the following links:

/usr/bin/gcc

/usr/bin/g++: undefined symbol: __errno__

These error messages indicate that your compiler cannot find an equivalent function named__errno__in the C standard library.

Solution:

To fix this issue, you will need to make some adjustments to your build process. Here is a step-by-step guide.

  • Install the GNU Compiler Collection (GCC):

On Ubuntu 20.04, you can install GCC using the following command:

sudo apt update

sudo apt install gcc-9

This version of GCC is compatible with Bitcoin Core.

  • Update the CXX and CPP flags:

After installing GCC, you will need to update the compiler flags for C++ and C code. The correct flags are:

gcc -std=c++11 -I/usr/include/gcc-9 -O2 -Wall -Wextra -pthread -I/usr/lib64/gcc/9/../../../glibc/aarch64-linux-gnu/libc.so -I/usr/local/include

The “CXX” and “CPP” flags are used to specify the compiler for C++ code. If you are using G++, replace “gcc” with “g++”.

  • Configure and build:

Now that you have the correct compiler flags, you can configure and build Bitcoin Core:

cd /path/to/bitcoin/src

./configure --enable-openssl=1 --prefix=/usr/local

make -j$ (nproc)

The --enable-openssl=1 flag enables the OpenSSL library to build with cryptography.

  • Run the installer:

After building Bitcoin Core, you will need to run the installer:

./installer --build --preinstall --no-synctool --config /usr/local/etc/bitcoin.conf

`

The “–config” option specifies a configuration file that contains your build settings. The path is relative to the current directory.

  • Verify:

Once the installation is complete, verify that Bitcoin Core was successfully installed and linked correctly:

bitcoind --version

This should display version information indicating that Bitcoin Core was built with the correct flags.

By following these steps, you should be able to fix the linking error and successfully build Bitcoin source code v24.2 for Windows using WSL running Ubuntu 20.04.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top