0

As my system updates to newer versions of certain libraries, monerod breaks every once in a while with errors among the likes of:

monerod: error while loading shared libraries: libunbound.so.2: cannot open shared object file: No such file or directory

I then recompile and the binary is back to a working state by having it realize that we're now at libunbound.so.8.

In order to avoid that necessity, I'd rather statically link the entire binary (ending up with one big single file).

A Stackoverflow answer on the topic suggests that success cannot be guaranteed, but maybe any of you has experience on this?

Maybe there's an even better way to permanently solve this? (No "symlink the old name to the new lib and cross fingers" please)

1
  • I read somewhere that a static build may require that boost be compiled with -fPIC.
    – user1425
    Commented Sep 18, 2018 at 13:08

2 Answers 2

2

You can't make static monero binaries. The closest you can do is a dynamic build which links statically against most libraries, such as boost, etc.

The Makefile has a number of predefined targets for this, called *static* (because close enough). For example:

  make release-static

You'll still end with a few dynamic libraries, but a lot fewer.

1
  • This is a little misleading. When the linker is asked to perform static linkage, all user supplied libraries have to be static and thus linked into the resulting binary. Only some system libraries can be dynamically linked and most systems provide as many libs as possible as static libs on development systems. This is so you can create binaries that work on things like win 7 and 10 with one build. You end up with a binary that is portable amongst any same system (e.g. Windows x86-64) regardless of whether that system doesn't have any of your user supplied libraries, such as unbound.
    – jtgrassie
    Commented Sep 23, 2018 at 13:24
1

More recently there are submodules in the Monero source tree, thus you must git submodule init && git submodule update from the root of a cloned repository.

Then to link statically, make release-static. I'd suggest running make clean first if you have been trying and failing beforehand.

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.