I am trying to use c++ code from the book of Antonopoulos for some time now and I seem to lack an include named bitcoin/bitcoin.hpp.

To compile the code the g++ compiler gets a pkg-config input with libbitcoin. So I suspect I would have to install this library.

Since the book does not mention to install anything else then bitcoin core I really wonder if parts of libbitcoin have originally been part of bitcoin core and have been excluded at some point.

The other explanation would be that the author forgot to mention it. But it seems a bit overload that I have to install another complete system for a full node (libbitcoin) to be able to run the code since the book explicitly says that running a full node with bitcoin core should suffice.

It is just a minor thing and probably laughable for an expert in the field but I am also learning how to use pkg-config and the compiler by doing this.

There have been suggestions to just install parts of libbitcoin but the developers said it is advisable to install the full thing with the automatic install skript.

Also, there is libbitcoin-dev, which is a package in debian (I run Raspbian Buster), but I was not able to compile the code with it.


2 Answers 2


libbitcoin is not, and was never a part of Bitcoin Core. Both are standalone implementations of the Bitcoin protocol.

Bitcoin Core, in its build process, will create a number of files named "libbitcoin_...". These are just locally generated files that are unrelated to the libbitcoin project.

Bitcoin Core does not have any files with the "hpp" extension. So are you sure you're actually trying to build Bitcoin Core?

  • I have built Bitcoin Core and I am running a full node. What I want is to compile a simple c++ code from the book "Mastering Bitcoin" which has an include named bitcoin/bitcoin.hpp and the compiler command from the book uses pkg-config --libs libbitcoin. So I am searching for the right library to install and I thought it should be libbitcoin.
    – bomben
    Commented Sep 20, 2019 at 17:28
  • That sounds like it's using libbitcoin indeed. Commented Sep 20, 2019 at 17:35
  • Yes, unfortunately, I was not able to compile it after I installed libbitcoin from source. But that was maybe due to the fact that I also installed the debian package libbitcoin-dev and then there was an issue with secpk256 and I think maybe the linker took the wrong way somewhere. But thanks anyway!
    – bomben
    Commented Sep 20, 2019 at 17:39
  • Add -lgmp to deal with the secpk256 linker errors.
    – daparic
    Commented May 19, 2021 at 12:10
  • FWIW, since recently libsecp256k1 master no longer depends on libgmp (not even optionally). Commented May 19, 2021 at 14:19

The libbitcoin library is a completely separate library and it is not part of the Bitcoin core reference implementation code.

The book code examples has an accompanying actively maintained github repo here. However, extra care is needed for the libbitcoin library dependency as it has new breaking changes. For example, #include <bitcoin/bitcoin.cpp> has been rename to #include <bitcoin/system.hpp>. And no more bc::ec_point. It is possible to install an older compatible version of libbitcoin library, but I prefer to use the latest version and made some adjustment in addr.cpp example code.

I manually build and installed the libbitcoin library to a custom location as suggested here.

mkdir -p /opt/my/libbitcoin/
$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
$ ./install.sh --prefix=/opt/my/libbitcoin/ --build-boost --disable-shared

And then I build addr.cpp by:

export PKG_CONFIG_PATH=/opt/my/libbitcoin/lib/pkgconfig/
g++ -o addr addr.cpp $(pkg-config --cflags --libs libbitcoin-system) -lgmp

Then run the executable by:

$ ./addr
Public key: 0202a406624211f2abbdc68da3df929f938c3399dd79fac1b51b0e4ad1d26a47aa
Address: 1PRTTaJesdNovgne6Ehcdu1fpEdX7913CK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.