4

I need to deploy to Linux box a native OCaml application that depends on several dynamic libraries. The idea is to prepare self-contained package (no dependencies on OCaml, OPAM etc.) that contains all stuff, and can be installed on hypothetically any modern x84 Linux box. In ideal world, there would be just a single file to be deployed and run.

The best I can think of is to deploy all needed dynamic libraries (ldd app.native) together with application executable and run application by means of bash script that exports LD_LIBRARY_PATH before calling application.

Any ideas how to make it better are welcome.

UPDATE

Some tips:

  • Use Linux Application Checker to verify compatibility with different Linux distributions.
  • Build a binary package on stable, but a bit outdated distribution (e.g. CentOS 6 for now) to improve libc compatibility.
  • Examples of scripts to build a binary package, and run an executable.
Stas
  • 11,571
  • 9
  • 40
  • 58
  • 1
    Am I mistaken to think that the "OCaml" aspect is quite secondary here ? I.e. that the question could be deploying a self-contained binary on linux. If not, could you point more precisely what the problem is. – Daniel Bünzli Apr 22 '15 at 22:24
  • @DanielBünzli yes, you're right, OCaml is secondary. – Stas Apr 22 '15 at 22:35

1 Answers1

6

OCaml with its all static approach should already work out of box. All OCaml executables are statically linked with OCaml libraries. What concerning non OCaml dependencies, then indeed you can deploy them with a wrapper script that sets LD_LIBRARY_PATH, or you can use rpath, or you can dlopen your libraries, if it makes sense for you. In any case I strongly suggest you not to treat libc in a such way, i.e., do not try to install your own version of libc.

ivg
  • 34,431
  • 2
  • 35
  • 63