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?

5
  • 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 Commented Nov 7, 2016 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. Commented Nov 7, 2016 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 Commented Nov 7, 2016 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. Commented Nov 7, 2016 at 16:32
  • Actually I am at this point because this was suggested after another question of my side on unix.stackexchange.com/questions/321592/… Commented Nov 7, 2016 at 16:32

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.