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

<p>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.</p>

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

CC BY-SA 4.0
2019-09-20T17:28:06.343Z
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
CC BY-SA 4.0
2019-09-20T17:35:29.570Z
That sounds like it's using libbitcoin indeed.
Pieter Wuille
CC BY-SA 4.0
2019-09-20T17:39:37.620Z
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
CC BY-SA 4.0
2021-05-19T12:10:16.010Z
Add `-lgmp` to deal with the `secpk256` linker errors.
daparic
CC BY-SA 4.0
2021-05-19T14:19:25.717Z
FWIW, since recently libsecp256k1 master no longer depends on libgmp (not even optionally).
Pieter Wuille
CC BY-SA 4.0
2019-09-20T16:44:03.903Z
2019-09-20T17:03:43.250Z
2019-09-20T17:03:43.250Z
Pieter Wuille
<p>The <code>libbitcoin</code> library is a completely separate library and it is not part of the Bitcoin core reference implementation code.</p>
<p>The book code examples has an accompanying actively maintained github repo <a href="https://github.com/bitcoinbook/bitcoinbook" rel="nofollow noreferrer">here</a>. However, extra care is needed for the <code>libbitcoin</code> library dependency as it has new breaking changes. For example, <code>#include &lt;bitcoin/bitcoin.cpp&gt;</code> has been rename to <code>#include &lt;bitcoin/system.hpp&gt;</code>. And no more <code>bc::ec_point</code>. It is possible to install an older compatible version of <code>libbitcoin</code> library, but I prefer to use the latest version and made some adjustment in <code>addr.cpp</code> example code.</p>
<p>I manually build and installed the <code>libbitcoin</code> library to a custom location as suggested <a href="https://github.com/libbitcoin/libbitcoin-system" rel="nofollow noreferrer">here</a>.</p>
<pre><code>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
</code></pre>
<p>And then I build <code>addr.cpp</code> by:</p>
<pre><code>export PKG_CONFIG_PATH=/opt/my/libbitcoin/lib/pkgconfig/
g++ -o addr addr.cpp $(pkg-config --cflags --libs libbitcoin-system) -lgmp
</code></pre>
<p>Then run the executable by:</p>
<pre><code>$ ./addr
Public key: 0202a406624211f2abbdc68da3df929f938c3399dd79fac1b51b0e4ad1d26a47aa
Address: 1PRTTaJesdNovgne6Ehcdu1fpEdX7913CK
</code></pre>

CC BY-SA 4.0
2021-05-19T12:07:16.847Z
2021-05-19T12:07:16.847Z
daparic
<p>I am trying to use <code>c++</code> code from the book of Antonopoulos for some time now and I seem to lack an <code>include</code> named <code>bitcoin/bitcoin.hpp</code>.</p>

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

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

<p>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 (<code>libbitcoin</code>) to be able to run the code since the book explicitly says that running a full node with <code>bitcoin core</code> should suffice. </p>

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

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

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

CC BY-SA 4.0
2019-09-20T14:56:59.847Z
Can you share what code exactly from which version of Mastering Bitcoin (?) you are trying to use? Maybe share a link or something?
0xb10c
CC BY-SA 4.0
2019-09-20T15:38:14.077Z
@0xb10c I have several questions open regarding this issue. https://bitcoin.stackexchange.com/questions/90239/how-to-update-an-older-c-code-from-antonopoulos-book-to-work-with-current-lib and https://stackoverflow.com/questions/57754502/do-i-have-to-install-libbitcoin-server-to-be-able-to-include-bitcoin-hpp
bomben
CC BY-SA 4.0
2022-01-18T03:05:37.233Z
What version of bitcoin and libbitcoin did you use?
Jeff
<bitcoind><c++><libbitcoin>
Was libbitcoin a part of bitcoin core in the past?
bomben
# Was libbitcoin a part of bitcoin core in the past?

(Asked by: username_0 on 2019-09-20)

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.

**Tags:** bitcoind, c++, libbitcoin

> **Comments:**
> **username_1**: Can you share what code exactly from which version of Mastering Bitcoin (?) you are trying to use? Maybe share a link or something?  
> **username_0**: @username_1 I have several questions open regarding this issue. https://bitcoin.stackexchange.com/questions/90239/how-to-update-an-older-c-code-from-antonopoulos-book-to-work-with-current-lib and https://stackoverflow.com/questions/57754502/do-i-have-to-install-libbitcoin-server-to-be-able-to-include-bitcoin-hpp  
> **username_2**: What version of bitcoin and libbitcoin did you use?  

---

## 2 answers

### Answer by username_3 on 2019-09-20. Score: 3 | Accepted answer

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?

> **Comments:**
> **username_0**: 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`.  
> **username_3**: That sounds like it's using libbitcoin indeed.  
> **username_0**: 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!  
> **username_4**: Add `-lgmp` to deal with the `secpk256` linker errors.  
> **username_3**: FWIW, since recently libsecp256k1 master no longer depends on libgmp (not even optionally).  

---

### Answer by username_4 on 2021-05-19. Score: 1

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](https://github.com/bitcoinbook/bitcoinbook). 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](https://github.com/libbitcoin/libbitcoin-system).

```
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

```


---

