How do I compile Bitcoin Core to be more portable? 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 &amp;&amp; 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.
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 and in the windows cross compilation docs.

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.