source: project/wiki/deploying linux binaries @ 38069

Last change on this file since 38069 was 21126, checked in by felix winkelmann, 9 years ago

some updates, removed user page on toplevel

File size: 3.3 KB
1== Deploying Linux binaries
3''(this page is obsolete, since deployment is now a built-in feature
4of recent CHICKEN versions)''
6If you want to deploy an application in binary form which uses many
7extensions ("eggs"), fiddling with compilation options can get quite
8involved and static linking might not always be practical.
10An alternative approach is to deploy a sort of "bundle": a directory
11containing all required binaries, libraries and extensions. On Linux
12system we can change the paths where the dynamic linker should search
13for libraries via the {{LD_LIBRARY_PATH}} environment
14variable. Extensions are loaded by the CHICKEN runtime system from the
15so-called repository, which can be set through the
16{{CHICKEN_REPOSITORY}} environment variable.
18So, to run a program inside a bundle, we have to set those two
19variables to the bundle directory and invoke the actual executable,
20for example in a start-script. There is one more problem, though: how
21can be call the startup script from an arbitrary location, or through
22a symbolic link (for example in {{/usr/local/bin}})? We have to find
23out the full path to the bundle-directory. Linux provides the
24{{/proc}} directory, where we can resolve the exe link to obtain the
25absolute path of a running executable. This only works for binaries,
26not shell scripts, so we require a little startup program that fetches
27its location from the {{/proc}} directory and invokes the actual
28program to set {{LD_IBRARY_PATH}} and {{CHICKEN_REPOSITORY}} and calls
29our real program. The source code for the "runner" program can be
33So, what do we have to place into the bundle?
35* The actual executable
37* The "linux-runner" program, compiled with {{-DPROGRAM='"<executable>"'}} and probably renamed to something more appropriate
39* Required libraries, including the CHICKEN runtime system (run {{ldd <executable>}} to get a list of libraries you need)
41* The extensions required at run-time - just copy the {{.so}} files from your repository into the bundle (you obtain the repository path by running {{csi -p "(repository-path)"}})
43Finally wrap up the directory into a tarball and distribute
44it. Starting the runner will execute your program with the necessary
45settings. Installation requires merely to copy the bundle into a safe
46location and (if needed) creating a symbolic link in your path to the
47runner program.
49Note: Solaris and *BSD have {{/proc}} filesystems too; it may require
50some work to adapt the "runner" program to them, as I don't know the
51details. --John Cowan
53Solaris does have {{/proc/$$/object/a.out}} entries, but they are a
54weird kind of hardlinks. I don't see a way to figure out your real
55path via the proc filesystem on Solaris. --Thomas Chust
57Note: You can always figure out your executable path in the classical
58way without relying on too much system support: Check if your zeroth
59command line argument contains a slash, if yes, prepend {{'./'}}
60unless the slash is the first character, if no, try to prepend each
61PATH entry and check for executability, finally expand to full real
62path. I have written something like this before, so here goes an
63adapted version: [[]]
64--Thomas Chust
66For Linux systems, [[|patchelf]]
67may also be of interest.
Note: See TracBrowser for help on using the repository browser.