0

I have a remote Unix server that I want to run various programs on. I can easily set up a local virtual machine running some flavour of Unix, on which I can compile my programs. The trouble is, it seems that moving a Unix program from one host to another always fails spectacularly. :-(

For example, I compiled test on an OpenSUSE 11.4 system, and tried to run it. It worked perfectly. But then I copied the compiled binary to a Debian 6.0.3 system, and now it refuses to run. Instead, I just get

test: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory

Presumably installing the compiler also installs all the dependencies - but only on the local machine. I would presumably have to somehow guess what dependencies I need to put on the remote machine.

On top of that, I don't have shell access to the remote machine. I only have FTP. So I can't install anything. I can only copy files to it. So I'm wondering whether I can just copy the necessary shared libraries to the same folder as the compiled binary. Would that work? Or would I have to do something more complex?

MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220
  • How are you executing the program on the remote machine without a shell? You're going to need to be able to set environment variables to show the location of your shared libraries most likely, unless you just statically link the whole thing. ( http://stackoverflow.com/questions/1437393/shared-libraries-in-same-folder-with-app-in-tcsh may help you, although without access to a shell, maybe not.) – Wooble Jul 19 '12 at 12:27
  • The binary is supposed to be run via CGI. Pointing a web browser at the appropriate URL causes the binary to run. Or, spit out a linker error - but not anywhere that I can read. :-( – MathematicalOrchid Jul 19 '12 at 12:29

1 Answers1

1

I think your best bet, given the circumstances, is to compile a static binary; see the -static option of gcc. However, this has downsides and might not always work.

You could also try to copy the shared libraries, but then you need to instruct the dynamic loader to search for the libraries in the location where you added them (your binary will have to be linked with the -Wl,-rpath,/path/to/libs switch.

Try the -static first. It should be easier.

If you wanna take a deeper look into the issues of binary portability, check out sources like:

Community
  • 1
  • 1
Unknown
  • 5,722
  • 5
  • 43
  • 64
  • I'm not using GCC, because the program isn't written in C. However, thanks to the links you provided, I discovered a system named `cde` which appears to do what I want. – MathematicalOrchid Jul 19 '12 at 14:09
  • Could you link a homepage/manpage for this ```cde``` ? I'm not aware of what it is/does. – Unknown Jul 19 '12 at 14:23