CRYPTOCURRENCY

Bitcoin: Bitcoin Core linking error

Bitcoin Core Linking Error on Windows using WSL and Ubuntu 20.04

As a user of Bitcoin, you’re likely familiar with the importance of ensuring that your software is compatible with various operating systems and environments. However, when building and installing Bitcoin Core, especially from source code, can be a frustrating experience. In this article, we’ll explore the linker error you’re experiencing on Windows using WSL (Windows Subsystem for Linux) running Ubuntu 20.04.

The Issue:

When trying to build Bitcoin Source code v24.2 for Windows using WSL, you might encounter the following linker errors:

/usr/bin/gcc

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

These error messages indicate that your compiler is unable to find an equivalent function named __errno__ in the C standard library.

The Solution:

To resolve this issue, you’ll need to make some adjustments to your build process. Here’s 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 CXX and CPP flags:

After installing GCC, you’ll need to update your 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. Replace gcc with g++ if you’re using G++.

  • Configure and Build

    Bitcoin: Bitcoin Core linking error

    :

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

cd /path/to/bitcoin/src

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

create -j$(nproc)

The --enable-openssl=1 flag enables the OpenSSL library for building with cryptography.

  • Run the Installer:

After building Bitcoin Core, you’ll 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 the settings for your build. The path is relative to the current directory.

  • Verify:

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

bitcoind --version

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

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

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *