2

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?

Valentin
  • 167
  • 2
  • 10
  • 2
    To get the `*.a` libraries you need to compile them, or have them compiles already. I don't see how could it be possible to convert from dynamic libraries to static ones – brainsandwich Nov 07 '16 at 16:17
  • Meanwhile I just installed gmp-static via yum, so one problem less. But unfortunately I think this is not so easy for the other ones. – Valentin Nov 07 '16 at 16:23
  • That's a step haha Why do you think you can't use dynamically linked libraries ? I never heard about supercomputers being annoying on that – brainsandwich Nov 07 '16 at 16:26
  • The shared library contains the same objects as the static library, but they are already linked to each other; I suppose that unlinking them (converting addresses back into symbolic references) is possible, but I know no easy way to do it. – Beta Nov 07 '16 at 16:32
  • Actually I am at this point because this was suggested after another question of my side on http://unix.stackexchange.com/questions/321592/use-supercomputer-to-run-a-program – Valentin Nov 07 '16 at 16:32

1 Answers1

3

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.

Community
  • 1
  • 1
Andrey Moiseev
  • 3,914
  • 7
  • 48
  • 64
  • I tried to use statifier but then I get the error "ElfClass '64' do not supported on this system." I am working on a 64 bit OS so why does this error appear? – Valentin Nov 07 '16 at 16:46