Valentin Valentin - 4 months ago 55
C++ Question

Linking libraries statically

I have to write a programm that should afterwards run on a supercomputer, so I got the hint I should link my libraries statically.

The problem is when I link

g++ -o calcrank -llinbox -lgivaro -lgmp -lntl -static -static-libstdc++ -static-libgcc calcrank.cpp
/usr/bin/ld: cannot find -llinbox
/usr/bin/ld: cannot find -lgivaro
/usr/bin/ld: cannot find -lgmp
/usr/bin/ld: cannot find -lntl
collect2: error: ld returned 1 exit status

Of course, all the libraries I used I have only available as *.so libraries instead of static *.a libraries. Is there a convenient way to convert the *.so libraries or any suggestions on how to proceed to get a self-conatined running program?


There are no easy ways, as far as I know.

There are some tools for "static linking" shared libraries:

  1. Statifier (open-source)
  2. Ermine (closed-source, paid)

You should probably ask about this, maybe you can bring shared libraries along and set the environment variable LD_LIBRARY_PATH to point to your shared libraries directory in a script before running your program.

As far as I remember Statifier didn't work for me. Ermine unlicensed gives some warnings and a 30-day limitation message, probably. So to distribute my thing across Linux systems with no admin rights I collected all needed shared libraries into a subdirectory, made a script that sets the env variable and launches my executable. And distributed it all as a zip.