[Ecls-list] Example about building / loading ECL libraries

Dietrich Bollmann dietrich at formgames.org
Thu May 30 07:33:37 UTC 2013


[The same message again - this time without the attachment - to make it
work with the sorgeforge.net mail archive. For the attachment see here:
http://sourceforge.net/mailarchive/attachment.php?list_name=ecls-list&message_id=CAMCvb%3DAZ4XtzpQ3kwc7qhjctNXTc5bhqWP0s4-cHVnhxXKf6AQ%40mail.gmail.com&counter=2]

Hi,

Thanks Juanjo!  This (and some adaptions) made it work on my windows host
as well :)

Dietrich

---
Just for the case that it might be helpful for somebody else here my
changes (I attached a tar file with the files adapted to my windows install
to this email).


* Usage (cygwin, 64 bit)

In a cygwin xterm:

$ tar zxvf embed-windows.tar.gz
$ cd embed-windows

  - Adapt the path of the batch file 'vcvars64.bat' in 'vsenv' to
correspond to the local installation of Microsoft Visual Studio.

  - Adapt the variable 'ECL_INSTALLATION_DIR' in 'Makefile' to point to the
ECL installation dir.

$ chmod 755 vsenv
$ ./vsenv nmake
$ ./hello.exe

hello-lisp!

$ ./vsenv nmake clean


* Changes to make the example work in a cygwin windows xterm

** vsenv

I used cygwin to compile and execute the example.

To set the environment required by the Microsoft Visual Studio 2010 x64
tools I created the script 'vsenv'.

'vsenv' generates a batch file which loads the environment required by the
Microsoft Visual Studio 2010 x64 tools via 'vcvars64.bat' and then executes
the command given on the remaining part of the command line.

The location of the script 'vcvars64.bat' on my computer has been hardcoded
into 'vsenv' and might have to be adapted.


** hello.c

Microsoft's C compiler requires that variable declarations are at top of
the scope they are used in.

I therefore had to move the 'extern void init_lib_HELLO_LISP(cl_object);'
declaration to the top of the 'main()' function.


** Makefile

I moved the lisp code to compile 'hello-lisp.lisp' into a static library
into the file 'compile.lisp' as nmake has problems with the blanks in the
lisp code;

I added the line to the lisp build code to switch from the default
bytecodes compiler to the c compiler as mentioned in Juanjo's email;

I extracted and adapted the necessary compiler and linker options from the
batch file 'ecl-config.bat'.  The paths had to be adapted as they didn't
correspond to the ECL installation directory.

On Wed, May 29, 2013 at 11:40 PM, Juan Jose Garcia-Ripoll <
juanjose.garciaripoll at gmail.com> wrote:

> add -eval '(ext:install-c-compiler)' or similar (clause copied from the
> ANNOUNCEMENT) before ASDF. You are using the bytecodes compiler by default
> and this does not allow building object files
>
>
> On Wed, May 29, 2013 at 3:22 PM, Dietrich Bollmann <dietrich at formgames.org
> > wrote:
>
>> Hi Juanjo,
>>
>> Thank you very much for this example!  Nothing is more helpful than some
>> working code to start from!
>>
>> On my windows installation, however, it still refuses to work:
>>
>> ecl.exe -norc \
>> >   -eval '(require :asdf)' \
>> >   -eval '(push "./" asdf:*central-registry*)' \
>> >   -eval '(asdf:make-build :hello-lisp :type :static-library :move-here
>> "./hello-lisp.lib")' \
>> >   -eval '(quit)'
>> ;;; Loading
>> #P"C:/Users/dietrich/home/cs/lang/lisp/ecl/64/git/install/asdf.fas"
>> An error occurred during initialization:
>> In COMPILE-FILE-PATHNAME, the type OBJECT is unsupported..
>>
>> Any idea what is going wrong?
>>
>> Thanks again,
>>
>> Dietrich
>>
>>
>> On Wed, May 29, 2013 at 6:10 AM, Juan Jose Garcia-Ripoll <
>> juanjose.garciaripoll at gmail.com> wrote:
>>
>>> I just cooked a trivial example
>>>    https://sourceforge.net/p/ecls/ecl/ci/master/tree/examples/embed/
>>>
>>> The example shows how to build a trivial Common Lisp package, compile it
>>> into a statically linked library using ECL and invoke it from a C program
>>> with which it is linked.
>>>
>>> It should be trivial to generalize it to using shared libraries and
>>> dlopen().
>>>
>>> Best,
>>>
>>> Juanjo
>>>
>>> --
>>> Instituto de Física Fundamental, CSIC
>>> c/ Serrano, 113b, Madrid 28006 (Spain)
>>> http://juanjose.garciaripoll.googlepages.com
>>>
>>
>>
>
>
> --
> Instituto de Física Fundamental, CSIC
> c/ Serrano, 113b, Madrid 28006 (Spain)
> http://juanjose.garciaripoll.googlepages.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130530/52939273/attachment.html>


More information about the ecl-devel mailing list