In this section we describe how you can use ECL to build programs and loadable extensions that you can later on distribute to other people.
Some day for some reasons you will be in the need to distribute code that has been developed using ECL. In the following sections we will describe the means that ECL offers you to do so. Basically, these are the alternatives
You distribute your programs in source code form. This is the easiest and most portable way, but not the fastest one.
You translate all your lisp code to C using the ECL compiler. The final object files can be linked against other C/C++ libraries to obtain a standalone executable.
You can build statically and dynamically linked libraries.
You translate all your lisp code to C and combine the resulting object files
into a single library with
You can build dynamically loadable files.
This is the most flexible way. You translate all lisp code to C and link it
against possibly other C/C++ libraries to obtain a dynamically loadable library
In several of these options, we have mentioned the possibility to include C/C++ code. Even if this is possible, you cannot use ordinary C/C++ compilers and makefiles to build ECL extensions, let it be programs or libraries. Briefly, you have to organize your code as follows
Organize the C code as a library, let it be static or dynamic.
Build a function, say
mymain(), in which the initialization phase
for your library is performed.
Group the code that interfaces to Lisp in separate C files, all of which
#include <ecl/ecl.h> at the beginning.
Compile your lisp source files.
Let ECL build the final executable or library.
In the final step there are ways to instruct ECL to call your
initialization function (
mymain() in the example above). These means
are explained in the following sections.