[Ecls-list] Embedding C++ code in LISP under Windows

Dietrich Bollmann dietrich at formgames.org
Mon Jun 17 04:21:18 UTC 2013


Hi Juanjo,

Thank you!

It was too late in the night when I wrote this email to think clearly:  I
tried to apply my experiences from embedding C++ code via the ECL FFI on my
Mac to Windows... Not a good strategy :)

In both cases I got the same error messages being caused by the compiler
misinterpreting the C++ code as C code.

In the case of my Mac recompiling ECL with '--with-cxx' was the solution.

On Windows, however, the problem is caused by 'asdf:make-build' generating
a file with the extension .c which makes the compiler interpreting the code
as C code.  The command line option /TP can be use to force the compiler to
interpret the content of the file as C++ code.  (See the page "/Tc, /Tp,
/TC, /TP (Specify Source File Type)" at
http://msdn.microsoft.com/en-us/library/032xwy55.aspx .)

Doing so a second error is thrown:  error C4716: 'main_lib_CUBE' : must
return a value ('cube' is the name I called the library). The
option /wo4716 can be used to turn it into a warning resulting in the
library being built. (See "/w, /Wn, /WX, /Wall, /wln, /wdn, /wen, /won
(Warning Level)" at http://msdn.microsoft.com/en-us/library/thxezb7y.aspx )

Here my current solution which builds the library:

In my Makefile:

--- Makefile---
...
cube.lib: cube.asd cube.lisp Cube.obj
ecl -norc -load cube-build.lisp
...
---

The file with the LISP code used to build the library:

---  cube-build.lisp ---
(ext:install-c-compiler)
(require :asdf)
(push "./" asdf:*central-registry*)
(let ((COMPILER::*cc-flags* (concatenate 'string COMPILER::*cc-flags* " /TP
/wo4716 "))
      (COMPILER::*ld-bundle-flags* (concatenate 'string
COMPILER::*ld-bundle-flags* " Cube.obj ")))
  (asdf:make-build :cube :type :static-library :move-here "./cube.lib"))
(quit)
---

On the long term a better solution might be

  - to add some option to 'asdf:make-build' which takes either ':c' or
'cpp' as value (with ':c' being the derault) and generates a file with the
respective extension;
  - to change the LISP to C / C++ compiler so that the generated function
'main_lib_NAMEOFLIBRARY' actually returns a value.

Thanks for you help,

Dietrich



On Mon, Jun 17, 2013 at 12:36 AM, Juan Jose Garcia-Ripoll <
juanjose.garciaripoll at gmail.com> wrote:

>
> On Sat, Jun 15, 2013 at 11:47 AM, Dietrich Bollmann <
> dietrich at formgames.org> wrote:
>
>>
>> How can I build ECL on Windows in a way which allows to embed C++ code as
>> well?
>>
>>
> The Windows compiler is a C++ compiler, AFAIK. You should not need to do
> anything extra.
>
>
> --
> 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/20130617/9027b531/attachment.html>


More information about the ecl-devel mailing list