<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>1.4. Building libraries</title><link rel="stylesheet" href="ecl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="ch24.html" title="Chapter 1. Building programs"><link rel="prev" href="ch24s03.html" title="1.3. Building standalone executables"><link rel="next" href="ch24s05.html" title="1.5. File names"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.4. Building libraries</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch24s03.html">Prev</a> </td><th width="60%" align="center">Chapter 1. Building programs</th><td width="20%" align="right"> <a accesskey="n" href="ch24s05.html">Next</a></td></tr></table><hr></div><div class="section" title="1.4. Building libraries"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Internals-Building-libraries"></a>1.4. Building libraries</h2></div></div></div><p>To build a library you proceed more or less the same way as with standalone executables. There are two different functions depending on whether you need to build static or shared libraries.</p><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id675580"></a>— Function: <code class="function">c:build-static-library</code> <code class="varname">{</code><code class="varname">library-name</code> <code class="varname">&key</code> <code class="varname">lisp-files</code> <code class="varname">prologue-code</code> <code class="varname">epilogue-code</code> <code class="varname">init-name</code><code class="varname">}</code></pre><pre class="screen"><a class="indexterm" name="id675623"></a>— Function: <code class="function">c:build-shared-library</code> <code class="varname">{</code><code class="varname">library-name</code> <code class="varname">&key</code> <code class="varname">lisp-files</code> <code class="varname">prologue-code</code> <code class="varname">epilogue-code</code> <code class="varname">ld-flags</code> <code class="varname">init-name</code><code class="varname">}</code></pre><p>This function builds a library file up from the object files listed in <em class="replaceable"><code>lisp-files</code></em>. Each of the arguments to <em class="replaceable"><code>lisp-file</code></em> must name a single object file produced with <code class="literal">compile-file</code>.</p><p><em class="replaceable"><code>library-name</code></em> is the physical pathname corresponding to the library. The value of <em class="replaceable"><code>library-name</code></em> must follow some system-specific conventions. To make your program portable, <em class="replaceable"><code>library-name</code></em> should be built using the output of <code class="literal">compile-file-pathname</code>.</p><p><em class="replaceable"><code>prologue-code</code></em> and <em class="replaceable"><code>epilogue-code</code></em> are strings with C code to be executed before and after initializing the library, respectively. For dynamically linked libraries you can also provide a list of strings in <em class="replaceable"><code>ld-flags</code></em>. These strings are additional parameters for the linker and their purpose is to link C/C++ extensions into the library.</p><p><em class="replaceable"><code>init-name</code></em> gives the initialization function of the library a user-specified name. Thus a the generated library may be used and/or linked to a C application. The recommended way to invoke <em class="replaceable"><code>init-name</code></em> is following: </p><pre class="programlisting"> cl_object the_block = read_VV(OBJNULL, init_FOO /* function name specified by init-name */); </pre><p> Be sure to call <code class="literal">cl_boot</code> before the invocation of <em class="replaceable"><code>init-name</code></em>. In order to avoid that the returned object is garbage collected, you should keep the result of <code class="literal">read_VV</code> in a local variable. </p></blockquote></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch24s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch24.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch24s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.3. Building standalone executables </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.5. File names</td></tr></table></div></body></html>