<div dir="ltr">[Connecting this thread to the one providing the answer]<div><br></div><div><div class="gmail_quote">On Wed, May 29, 2013 at 2:42 AM, Dietrich Bollmann <span dir="ltr"><<a href="mailto:dietrich@formgames.org" target="_blank">dietrich@formgames.org</a>></span> wrote: </div>
<div class="gmail_quote"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">
How can I make this simple example work?</div></blockquote><div> </div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div>the ideal procedure would be something like this</div><div><br></div><div>  - translate lisp files to c files</div><div>  - compile c files to object files</div><div>  - link the object files</div></div>
</blockquote><div> </div></div>See this thread for the solution:<br><br>  - [Ecls-list] Example about building / loading ECL libraries<br>    <a href="http://sourceforge.net/mailarchive/forum.php?thread_name=CAMCvb%3DCyzbkyVJqNumSeozg8-Vn4ErO2ytS%3D7ui175HcQeYbsw%40mail.gmail.com&forum_name=ecls-list">http://sourceforge.net/mailarchive/forum.php?thread_name=CAMCvb%3DCyzbkyVJqNumSeozg8-Vn4ErO2ytS%3D7ui175HcQeYbsw%40mail.gmail.com&forum_name=ecls-list</a><br>
<br>Dietrich<div><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 29, 2013 at 2:42 AM, Dietrich Bollmann <span dir="ltr"><<a href="mailto:dietrich@formgames.org" target="_blank">dietrich@formgames.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>I have the following lisp file:</div>
<div><br></div><div>---</div><div>$ cat hello-lisp.lisp</div><div><br></div><div>(defun hello-lisp () (format t "hello-lisp!~%"))</div>
<div>---</div><div><br></div><div>and would like to call the function (hello-lisp) from the following c file:</div><div><br></div><div>---</div><div>$ cat hello.c</div><div><br></div><div>#include <stdio.h></div><div>

#include <ecl/ecl.h></div><div><br></div><div>int main (int argc, char **argv) {</div><div>  cl_boot(argc, argv);</div><div><br></div><div>  // evaluating (hello-lisp)</div><div>  cl_eval(c_string_to_object("(hello-lisp)"));</div>

<div><br></div><div>  cl_shutdown();</div><div>  return 0;</div><div>}</div><div>---</div><div><br></div><div>On my Mac I compiled and linked the files as follows:</div><div><br></div><div>---</div><div>ecl -eval '(compile-file "hello-lisp.lisp" :system-p t)' -eval '(quit)'</div>

<div>gcc -Wall -c `ecl-config --cflags` -c hello.c</div><div>gcc -Wall -o hello `ecl-config --libs` hello-lisp.o hello.o</div><div>---</div><div><br></div><div>But when executing the file 'hello' I get the following error:</div>

<div><br></div><div>---</div><div>./hello </div><div><br></div><div>Condition of type: UNDEFINED-FUNCTION</div><div>The function HELLO-LISP is undefined.</div><div>No restarts available.</div><div><br></div><div>Top level in: #<process TOP-LEVEL>.</div>

<div>></div><div>---</div><div><br></div><div>I tried to solve this problem by including the hello-lisp.eclh file which is generated when using (compile-file "hello-lisp.lisp" :h-file t) but this didn't solve the problem either.  I am not yet able to understand the generated c code and therefore don't understand how to use it correctly.</div>

<div><br></div><div>How can I make this simple example work?</div><div><br></div><div><div>Thanks, </div><div><br></div><div>Dietrich</div></div><div><br></div><div>I am currently working on a Mac but ultimately have to make the example work with MS VC++.  This is why I prefer to call the c compiler and linker myself rather than using ECLs lisp based build tools like c::build-program, etc.  </div>

<div><br></div><div>For the same reason I would also prefer to separate the translation of lisp files into c and object files.  But I couldn't find a way to compile a lisp file to c without producing an object or fasl file in the same time as it is done when using (compile-file ...).  I tried ':o-file nil' but even if this parameter is mentioned in the help text of (compile-file ...) it seems to not have been implemented yet.  I would be grateful about help concerning this point as well.</div>

<div><br></div><div>So the ideal procedure would be something like this</div><div><br></div><div>  - translate lisp files to c files</div><div>  - compile c files to object files</div><div>  - link the object files</div>

<div><br></div><div>as this would be easier to integrate with MS VC++.</div><div><br></div><div><br></div><div><br></div></div>
</blockquote></div><br></div></div></div></div>