Hi again,

Compiling the files manually with 'compile-file' and building the shared library with 'c:build-shared-library' works on Windows as well:

---
(ext:install-c-compiler)
(compile-file "hello-lisp.lisp" :c-file "hello-lisp.c" :h-file "hello-lisp.h" :data-file "hello-lisp.data" :system-p t)
(c:build-shared-library "hello-lisp" :lisp-files '("hello-lisp.obj") :init-name "init_lib_HELLO_LISP")
(quit)
---

I suppose that 'asdf:make-build' is based on the same functions and wonder why it didn't work...

The example sources which work on my Windows installation can be found here: http://formgames.org/lisp/ecl/examples/shared-library.tar.gz

I made a wiki page for my own entertainment: http://formgames.org/wiki/ECL/Building_libraries :)

If you think that it makes sense to publish it on the ECL wiki, please let me know.

Thanks for your help,

Dietrich


On Tue, Jun 25, 2013 at 12:26 AM, Dietrich Bollmann <dietrich@formgames.org> wrote:
>
> Hi Juanjo,
>
> Sorry for being unclear!
>
> The example sources in embed-windows.tar from the email
>
>   - Re: [Ecls-list] Example about building / loading ECL libraries
>     http://sourceforge.net/mailarchive/message.php?msg_id=30912414
>
> (see 'embed-windows.tar', http://sourceforge.net/mailarchive/attachment.php?list_name=ecls-list&message_id=CAMCvb%3DAZ4XtzpQ3kwc7qhjctNXTc5bhqWP0s4-cHVnhxXKf6AQ%40mail.gmail.com&counter=2 )
>
> show how to compile the files hello-lisp.asd and hello-lisp.lisp on Windows into the static library hello-lisp.lib which than is used to build hello.exe from hello.c.
>
> the line
>
> ecl -norc -load compile.lisp
>
> in the Makefile is responsible for building the static library based on the lisp build file compile.lisp:
>
> === compile.lisp ===
> (ext:install-c-compiler)
> (require :asdf)
> (push "./" asdf:*central-registry*)
> (asdf:make-build :hello-lisp :type :static-library :move-here "./")
> (quit)
> ===
>
> So my fist and probably naive attempt to build a shared library was to change ':type :static-library' to ':type :shared-library' resulting in the following file:
>
> === compile.lisp ===
> (ext:install-c-compiler)
> (require :asdf)
> (push "./" asdf:*central-registry*)
> (asdf:make-build :hello-lisp :type :shared-library :move-here "./")
> (quit)
> ===
>
> But unfortunately nothing happens when trying to use this file to build a shared library:
>
> $ ls -la
>
> total 28
> drwxr-xr-x 1 dietrich    0 Jan  1  1970 .
> drwxr-xr-x 1 dietrich    0 Jan  1  1970 ..
> -rw-r--r-- 1 dietrich  636 Jun 24 23:44 compile.lisp
> -rw-r--r-- 1 dietrich  453 Jun 24 23:44 hello.c
> -rw-r--r-- 1 dietrich   64 Jun 24 23:44 hello-lisp.asd
> -rw-r--r-- 1 dietrich   48 Jun 24 23:44 hello-lisp.lisp
> -rw-r--r-- 1 dietrich 1259 Jun 24 23:44 Makefile
> -rw-r--r-- 1 dietrich  342 Jun 24 23:44 README
> -rw-r--r-- 1 dietrich  528 Jun 24 23:44 vsenv
>
> $ ./vsenv ecl.exe -norc -load compile.lisp
>
> Setting environment for using Microsoft Visual Studio 2010 x64 tools.
> ;;; Loading "E:/Users/dietrich/home/cs/lang/lisp/ecl/diary/2013/06/24/windows/dynamic-link-libraries/bastel100/v100/shared-lib/embed-windows/compile.lisp"
> ;;; Loading #P"C:/Users/dietrich/home/cs/lang/lisp/ecl/64/git/install/cmp.fas"
> ;;; Loading #P"C:/Users/dietrich/home/cs/lang/lisp/ecl/64/git/install/asdf.fas"
>
> $ ls -la
>
> total 28
> drwxr-xr-x 1 dietrich    0 Jan  1  1970 .
> drwxr-xr-x 1 dietrich    0 Jan  1  1970 ..
> -rw-r--r-- 1 dietrich  636 Jun 24 23:44 compile.lisp
> -rw-r--r-- 1 dietrich  453 Jun 24 23:44 hello.c
> -rw-r--r-- 1 dietrich   64 Jun 24 23:44 hello-lisp.asd
> -rw-r--r-- 1 dietrich   48 Jun 24 23:44 hello-lisp.lisp
> -rw-r--r-- 1 dietrich 1259 Jun 24 23:44 Makefile
> -rw-r--r-- 1 dietrich  342 Jun 24 23:44 README
> -rw-r--r-- 1 dietrich  528 Jun 24 23:44 vsenv
>
> So now I wonder what I have to do in order to build a shared library...
>
> One approach would be to change the Makefile and / or the compile.lisp file, but I am not sure how;
>
> another one might be to compile the lisp files to .h, .c, .data files first and build a shared library "by hand" using 'cl' and 'link'.
>
> Which approach would be the better one?  
>
> Or is there some better way to solve this problem?
>
> Thanks again,
>
> Dietrich
>
>
>
>
>
>
>
>
>
> On Mon, Jun 24, 2013 at 9:50 PM, Juan Jose Garcia-Ripoll <juanjose.garciaripoll@gmail.com> wrote:
>>
>>
>> On Mon, Jun 24, 2013 at 2:34 PM, Dietrich Bollmann <dietrich@formgames.org> wrote:
>>>
>>> Using :shared-library at the place of :static-library in the asdf:make-build command seems not to be enough - at least not under Windows.
>>
>>
>> What does it mean "not enough". Please, be more accurate on your reports.
>>
>>
>>
>> --
>> Instituto de Física Fundamental, CSIC
>> c/ Serrano, 113b, Madrid 28006 (Spain)
>> http://juanjose.garciaripoll.googlepages.com
>
>