<p>By default, the binaries that you build are dynamically linked. This means that they use libraries installed in standard search paths on your computer. What you want is a statically linked binary where those libraries are packaged together with the binary.</p>

<p>Bitcoin Core achieves this by using the "depends" system. Documentation for this can be found <a href="https://github.com/bitcoin/bitcoin/tree/master/depends" rel="nofollow noreferrer">here</a> and in the <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md#building-for-64-bit-windows" rel="nofollow noreferrer">windows cross compilation docs</a>.</p>

<p>Basically, you <code>cd</code> into the <code>depends</code> directory, run <code>make</code> in there, then back in the root directory, you configure and point to the configuration stuff produced by the depends system, and when you compile with <code>make</code>, it will use the libraries build in the depends system and be statically linked.</p>

<p>For example, you might do these commands:</p>

<pre><code>cd depends
make HOST=x86_64-pc-linux-gnu
cd ..
./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site ./configure --prefix=/
make
</code></pre>

<p><code>x86_64-pc-linux-gnu</code> is the platform that you want to build binaries for. The depends system will create a directory in <code>depends/</code> with that name. That directory contains the depend system's build results.</p>

<p>The resulting binaries should be portable.</p>

CC BY-SA 4.0
2020-06-06T19:33:01.697Z
That did it, thanks! I ran make in the depends directory as you mentioned, but changed the ./configure line to the following: ./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu and it worked great
Mike
CC BY-SA 4.0
2022-01-05T21:57:05.883Z
@Mike this will move your binaries to `$PWD/depends/x86_64-pc-linux-gnu` right?
Martin Braun
CC BY-SA 4.0
2020-06-06T05:36:24.367Z
2020-06-06T05:36:24.367Z
Ava Chow
<p>Background: I compile bitcoind on one system but run it on another. When I compiled bitcoind 0.19.1 some time back using the following method, I was able to run bitcoind and bitcoin-cli on the target system without issue</p>

<pre><code>./autogen.sh
./configure --disable-wallet --disable-tests --disable-bench --disable-gui --enable-util-tx=no --prefix=$HOME/bitcoind/x64 --exec-prefix=$HOME/bitcoind/x64
make &amp;&amp; make install
</code></pre>

<p>Today I compiled v0.20.0 using the same method. If I run ./bitcoind -version on the system I compiled the binary it runs fine, but if I take the binary to my target system I get the following error:</p>

<pre><code>./bitcoind: error while loading shared libraries: libboost_filesystem.so.1.67.0: cannot open shared object file: No such file or directory
</code></pre>

<p>The binary seemed to be portable last time, and the pre-compiled binary I download from the Bitcoin Core team runs fine. </p>

<p>Note that on the target system <code>libboost-filesystem-dev</code> and <code>libboost-filesystem1.67-dev</code> are not installed, this is likely the source of my error. That said, running the pre-compiled binary from the Core team runs, so why doesn't mine?</p>

<p>Can someone help me understand if I did something wrong or if I need to add ./configure flags to make the binary more portable? Specifically what I likely did differently than the core developers that made my binary fail where theirs worked?</p>

<p>EDIT 1: Running <code>./configure --enable-static</code> or <code>./configure LDFLAGS=-static</code> does not result in a portable binary either.</p>

<p>Also note that installing libboost-filesystem library with apt does fix the error.</p>

<bitcoind><make>
How do I compile Bitcoin Core to be more portable?
Mike
# How do I compile Bitcoin Core to be more portable?

(Asked by: username_0 on 2020-06-05)

Background: I compile bitcoind on one system but run it on another. When I compiled bitcoind 0.19.1 some time back using the following method, I was able to run bitcoind and bitcoin-cli on the target system without issue

```
./autogen.sh
./configure --disable-wallet --disable-tests --disable-bench --disable-gui --enable-util-tx=no --prefix=$HOME/bitcoind/x64 --exec-prefix=$HOME/bitcoind/x64
make && make install

```

Today I compiled v0.20.0 using the same method. If I run ./bitcoind -version on the system I compiled the binary it runs fine, but if I take the binary to my target system I get the following error:

```
./bitcoind: error while loading shared libraries: libboost_filesystem.so.1.67.0: cannot open shared object file: No such file or directory

```

The binary seemed to be portable last time, and the pre-compiled binary I download from the Bitcoin Core team runs fine.

Note that on the target system `libboost-filesystem-dev` and `libboost-filesystem1.67-dev` are not installed, this is likely the source of my error. That said, running the pre-compiled binary from the Core team runs, so why doesn't mine?

Can someone help me understand if I did something wrong or if I need to add ./configure flags to make the binary more portable? Specifically what I likely did differently than the core developers that made my binary fail where theirs worked?

EDIT 1: Running `./configure --enable-static` or `./configure LDFLAGS=-static` does not result in a portable binary either.

Also note that installing libboost-filesystem library with apt does fix the error.

**Tags:** bitcoind, make


---

## 1 answers

### Answer by username_1 on 2020-06-06. Score: 2 | Accepted answer

By default, the binaries that you build are dynamically linked. This means that they use libraries installed in standard search paths on your computer. What you want is a statically linked binary where those libraries are packaged together with the binary.

Bitcoin Core achieves this by using the "depends" system. Documentation for this can be found [here](https://github.com/bitcoin/bitcoin/tree/master/depends) and in the [windows cross compilation docs](https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md#building-for-64-bit-windows).

Basically, you `cd` into the `depends` directory, run `make` in there, then back in the root directory, you configure and point to the configuration stuff produced by the depends system, and when you compile with `make`, it will use the libraries build in the depends system and be statically linked.

For example, you might do these commands:

```
cd depends
make HOST=x86_64-pc-linux-gnu
cd ..
./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site ./configure --prefix=/
make

```

`x86_64-pc-linux-gnu` is the platform that you want to build binaries for. The depends system will create a directory in `depends/` with that name. That directory contains the depend system's build results.

The resulting binaries should be portable.

> **Comments:**
> **username_0**: That did it, thanks! I ran make in the depends directory as you mentioned, but changed the ./configure line to the following: ./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu and it worked great  
> **username_2**: @username_0 this will move your binaries to `$PWD/depends/x86_64-pc-linux-gnu` right?  

---

