<p>I've just started learning Lisp and I can't figure out how to compile and link lisp code to an executable.</p>

<p>I'm using <code>clisp</code> and <code>clisp -c</code> produces two files:</p>

<ul>
<li>.fas</li>
<li>.lib</li>
</ul>

<p>What do I do next to get an executable?</p>

[{'answer_id': 25057, 'author': 'Patrik Svensson', 'author_id': 936, 'author_profile': 'https://Stackoverflow.com/users/936', 'pm_score': 4, 'selected': False, 'text': '<p>Take a look at the the official clisp homepage. There is a FAQ that answers this question.</p>\n\n<p><a href="http://clisp.cons.org/impnotes/faq.html#faq-exec" rel="noreferrer">http://clisp.cons.org/impnotes/faq.html#faq-exec</a></p>\n'}, {'answer_id': 25435, 'author': 'thekidder', 'author_id': 1631, 'author_profile': 'https://Stackoverflow.com/users/1631', 'pm_score': 7, 'selected': True, 'text': '<p>I was actually trying to do this today, and I found typing this into the CLisp REPL worked:</p>\n\n<pre><code>(EXT:SAVEINITMEM "executable.exe"\n                 :QUIET t\n                 :INIT-FUNCTION \'main\n                 :EXECUTABLE t\n                 :NORC t)\n</code></pre>\n\n<p>where main is the name of the function you want to call when the program launches, <code>:QUIET t</code> suppresses the startup banner, and <code>:EXECUTABLE t</code> makes a native executable. </p>\n\n<p>It can also be useful to call </p>\n\n<pre><code>(EXT:EXIT)\n</code></pre>\n\n<p>at the end of your main function in order to stop the user from getting an interactive lisp prompt when the program is done.</p>\n\n<p>EDIT: Reading the documentation, you may also want to add <code>:NORC t</code>\n(read <a href="http://clisp.cons.org/impnotes/image.html" rel="nofollow noreferrer">link</a>). This suppresses loading the RC file (for example, <code>~/.clisprc.lisp</code>).</p>\n'}, {'answer_id': 31332, 'author': 'Luís Oliveira', 'author_id': 2967, 'author_profile': 'https://Stackoverflow.com/users/2967', 'pm_score': 5, 'selected': False, 'text': '<p>This is a <a href="http://code.google.com/p/lispfaq/" rel="noreferrer">Lisp FAQ</a> (slightly adapted):</p>\n\n<blockquote>\n  <p><strong>*** How do I make an executable from my programme?</strong></p>\n  \n  <p>This depends on your implementation; you will need to consult your\n  vendor\'s documentation.</p>\n  \n  <ul>\n  <li><p>With ECL and GCL, the standard compilation process will\n   produce a native executable.</p></li>\n  <li><p>With LispWorks, see the <em>Delivery User\'s Guide</em> section of the\n   documentation.</p></li>\n  <li><p>With Allegro Common Lisp, see the <em>Delivery</em> section of the\n   manual.</p></li>\n  <li><p>etc...</p></li>\n  </ul>\n  \n  <p>However, the classical way of interacting with Common Lisp programs\n    does not involve standalone executables. Let\'s consider this during\n    two phases of the development process: programming and delivery.</p>\n  \n  <p><em>Programming phase</em>: Common Lisp development has more of an\n    incremental feel than is common in batch-oriented languages, where an\n    edit-compile-link cycle is common. A CL developer will run simple\n    tests and transient interactions with the environment at the\n    REPL (or Read-Eval-Print-Loop, also known as the\n    <em>listener</em>). Source code is saved in files, and the build/load\n    dependencies between source files are recorded in a system-description\n    facility such as ASDF (which plays a similar role to <em>make</em> in\n    edit-compile-link systems). The system-description facility provides\n    commands for building a system (and only recompiling files whose\n    dependencies have changed since the last build), and for loading a\n    system into memory.</p>\n  \n  <p>Most Common Lisp implementations also provide a "save-world" mechanism\n    that makes it possible to save a snapshot of the current lisp image,\n    in a form which can later be restarted. A Common Lisp environment\n    generally consists of a relatively small executable runtime, and a\n    larger image file that contains the state of the lisp world. A common\n    use of this facility is to dump a customized image containing all the\n    build tools and libraries that are used on a given project, in order\n    to reduce startup time. For instance, this facility is available under\n    the name EXT:SAVE-LISP in CMUCL, SB-EXT:SAVE-LISP-AND-DIE in\n    SBCL, EXT:SAVEINITMEM in CLISP, and CCL:SAVE-APPLICATION in\n    OpenMCL. Most of these implementations can prepend the runtime to the\n    image, thereby making it executable.</p>\n  \n  <p><em>Application delivery</em>: rather than generating a single executable\n    file for an application, Lisp developers generally save an image\n    containing their application, and deliver it to clients together with\n    the runtime and possibly a shell-script wrapper that invokes the\n    runtime with the application image. On Windows platforms this can be\n    hidden from the user by using a click-o-matic InstallShield type tool.</p>\n</blockquote>\n'}, {'answer_id': 1045226, 'author': 'Luís Oliveira', 'author_id': 2967, 'author_profile': 'https://Stackoverflow.com/users/2967', 'pm_score': 4, 'selected': False, 'text': '<p>CLiki has a good answer as well: <a href="http://www.cliki.net/Creating%20Executables" rel="noreferrer">Creating Executables</a></p>\n'}, {'answer_id': 34195243, 'author': 'Thayne', 'author_id': 2543666, 'author_profile': 'https://Stackoverflow.com/users/2543666', 'pm_score': 2, 'selected': False, 'text': '<p>For a portable way to do this, I recommend <a href="https://github.com/snmsts/roswell" rel="nofollow">roswell</a>.</p>\n\n<p>For any supported implementation you can create lisp scripts to run the program that can be run in a portable way by <code>ros</code> which can be used in a hash-bang line similarly to say a python or ruby program. </p>\n\n<p>For SBCL and CCL roswell can also create binary executables with <code>ros dump executable</code>.</p>\n'}, {'answer_id': 45891272, 'author': 'Paul McCarthy', 'author_id': 2158599, 'author_profile': 'https://Stackoverflow.com/users/2158599', 'pm_score': -1, 'selected': False, 'text': '<p>I know this is an old question but the Lisp code I\'m looking at is 25 years old :-)</p>\n\n<p>I could not get compilation working with clisp on Windows 10.\nHowever, it worked for me with <a href="https://www.cs.utexas.edu/users/novak/gclwin.html" rel="nofollow noreferrer">gcl</a>.</p>\n\n<p>If my lisp file is jugs2.lisp,</p>\n\n<pre><code>gcl -compile jugs2.lisp\n</code></pre>\n\n<p>This produces the file jugs2.o if jugs2.lisp file has no errors.</p>\n\n<p>Run gcl with no parameters to launch the lisp interpreter:</p>\n\n<pre><code>gcl\n</code></pre>\n\n<p>Load the .o file:</p>\n\n<pre><code>(load "jugs2.o")\n</code></pre>\n\n<p>To create an EXE:</p>\n\n<pre><code>(si:save-system "jugs2")\n</code></pre>\n\n<p>When the EXE is run it needs the DLL <code>oncrpc.dll</code>; this is in the <code>&lt;gcl install folder&gt;\\lib\\gcl-2.6.1\\unixport</code> folder that gcl.bat creates.</p>\n\n<p>When run it shows a lisp environment, call (main) to run the main function\n(main).</p>\n'}]
['https://Stackoverflow.com/questions/25046', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2450/']