You are looking at historical revision 18489 of this page. It may differ significantly from its current revision.


CHICKEN generates fully native binaries that can be distributed like normal C/C++ programs. There are various methods of deployment, depending on platform, linkage, external dependencies and whether the application should be built from sources or precompiled and whether the CHICKEN runtime-libraries are expected on the destination system or if the application should be completely self-contained.

Simple executables

The simplest form of deployment is the single executable. The runtime libraries ( or libchicken.dll is required for these programs to run, unless you link your application statically:

 % csc myprogram.scm
 % ldd myprogram               # on linux
  =>  (0xb805c000)
  => /home/felix/chicken/core/lib/ (0xb7c22000)
  => /lib/tls/i686/cmov/ (0xb7bec000)
  => /lib/tls/i686/cmov/ (0xb7be7000)
  => /lib/tls/i686/cmov/ (0xb7a84000)
           /lib/ (0xb805d000)
 % ls -l myprogram
 -rwxr-xr-x 1 felix felix   34839 2010-02-22 20:19 x

Linking your application statically will include the runtime library in the executable, but this will increase its size substantially:

 % ls myprogram
 -rwxr-xr-x 1 felix felix 3566656 2010-02-22 20:30 myprogram

Programs distributed this way can only use Extensions if these extensions get linked in statically, which is basically supported but not available for all extensions.

Self contained applications

The solution to many of these problems is creating an application directory that contains the executable, the runtime libraries, extensions and additional support files needed by the program. The executable has to be linked specially to make sure the correct included runtime library is used. You do this by using the -deploy options provided by the compiler driver, csc:

 % csc -deploy myprogram.scm
 % ls -l myprogram
 -rwxr-xr-x 1 felix felix 7972753 2010-02-22 20:19
 -rwxr-xr-x 1 felix felix   34839 2010-02-22 20:19 myprogram
 % ldd myprogram =>  (0xb806a000) => /home/felix/tmp/myprogram/ (0xb7c30000) => /lib/tls/i686/cmov/ (0xb7bfa000) => /lib/tls/i686/cmov/ (0xb7bf5000) => /lib/tls/i686/cmov/ (0xb7a92000)
         /lib/ (0xb806b000)

As can be seen here, myprogram is prepared to load the contained libchicken, not any installed in the system that happens to have the same name.

You can even install extensions inside the application directory:

 % chicken-install -deploy -p $PWD/myprogram defstruct
 % ls -l myprogram
 -rwxr-xr-x 1 felix felix   82842 2010-02-22 20:24
 -rw-r--r-- 1 felix felix     182 2010-02-22 20:24 defstruct.setup-info
 -rwxr-xr-x 1 felix felix   11394 2010-02-22 20:24
 -rwxr-xr-x 1 felix felix 7972753 2010-02-22 20:19
 -rwxr-xr-x 1 felix felix   34839 2010-02-22 20:19 myprogram

We can check with ldd that those compiled extension libraries are linked with the correct library:

 % ldd myprogram/*.so
 /home/felix/tmp/myprogram/ =>  (0xb7f4f000) => /home/felix/tmp/myprogram/ (0xb7b08000) => /lib/tls/i686/cmov/ (0xb7ad2000) => /lib/tls/i686/cmov/ (0xb7acd000) => /lib/tls/i686/cmov/ (0xb796a000)
         /lib/ (0xb7f50000)
 /home/felix/tmp/myprogram/ =>  (0xb80c9000) => /home/felix/tmp/myprogram/ (0xb7c8c000) => /lib/tls/i686/cmov/ (0xb7c56000) => /lib/tls/i686/cmov/ (0xb7c51000) => /lib/tls/i686/cmov/ (0xb7aee000)
         /lib/ (0xb80ca000)

The -deploy option passed to csc when compiling myprogram.scm has taken care of setting up the application directory as the "repository" for extensions that the program will use at runtime:

 % myprogram/myprogram -:d
 [debug] application startup...
 [debug] heap resized to 500000 bytes
 [debug] stack bottom is 0xbfdbdf60.
 [debug] entering toplevel toplevel...
 [debug] stack resized to 131072 bytes
 [debug] entering toplevel library_toplevel...
 [debug] entering toplevel eval_toplevel...
 [debug] entering toplevel expand_toplevel...
 [debug] loading compiled module `/home/felix/tmp/myprogram/' (handle is 0x886ce98)

There is one restriction that you should be aware of, though: any extension that you install inside an application directory must first be installed system-wide (unless you use a custom repository with the CHICKEN_REPOSITORY environment variable), so that csc/chicken will find an import library for the extension. Just make sure you have all the extensions installed that you use in an application (something you will normally have anyway).

You can execute the program from its location, or you can install a symbolic link pointing to it - it will find the correct directory where the actual executable is located.

The application directory is fully "portable" in the sense that it will run directly from an USB-stick or any other removable media. At runtime the program can find out its location by invoking the repository-path procedure, which will return the full pathname in which the application is located.

Should the program depend on more libraries which are not available by default on the intended target systems, and which you would like to include in your application, you will have to hunt them down yourself and place them in the application directory. If these again have dependencies, things will get complicated and will involve things like patching binaries or writing "trampoline" shell scripts to run your application.

Platform-specific notes


Deployment is fully suppored on Linux


Deployment is fully supported on Windows. Since Windows looks up dynamic link libraries in the programs original location by default, adding third-party libraries to the application directory is no problem. The freely available depends tool is helpful to find out what DLLs your application depends on:


On the Macintosh, passing the -gui option to csc will result in a true GUI application bundle (named <your-program>.app).


 % otool -L <yourprogram>

will list dynamic libraries that your application needs.

Other UNIX flavors

Setting up the application executable to load runtime libraries from the same directory is supported on FreeBSD, OpenBSD and Solaris. NetBSD supports this from version 5.0 onwards - this is currently disabled in csc for this particular platform.

Deploying source code

An alternative to deploying binaries is deployment as compiled C sources. Usually, you just need to ship your application code, compiled to .c files and the chicken.h and runtime.c files from the CHICKEN sources. You will also need the .c files of any library units your program uses. Compiling everything and linking it together should work on most systems. Consult the CHICKEN makefiles for more information about optimization options, etc.

Previous: Extensions

Next: Data representation