Dietrich Bollmann | 19 May 2013 12:40

SIMPLE-ERROR: In interpreted code, attempted to call a foreign function but ECL was build without support for that.

Hi,

I am trying to use ECL as scripting language for the 3D modelling software Rhino3D.  The idea is to call a lisp script with something like

  lisp /path/to/the/script.lisp

from the rhino command shell.  In the lisp script I would make use of the foreign function interface to call Rhino C++ commands for creating and manipulating Rhino 3D geometry.

Looking at the sources I had the impression that CFFI is the best way to make the Rhino C++ API accessible from lisp. (Please tell me if this is not the case and some other method should be used.)  With CFFI it might be even possible to generate the lisp wrappers automatically using SWIG.

In order to understand CFFI better I decided to start with the FFI examples in the ecl/examples/ffi/ directory of the ECL source tree.  But when trying to compile and load the cffi.lsp example using my 64 bit windows compile of ECL with

  (compile-file "cffi.lsp" :load t)

I get the following error message:

  In interpreted code, attempted to call a foreign function
   #<foreign POINTER-VOID>
  but ECL was build without support for that.

In ecl/src/configure I found the option 

  --with-dffi             dynamic foreign function interface
                          (system|included|auto|no, default=AUTO if libffi
                          available)

But I couldn't find anything similar in the windows ecl/msvc/Makefile.

How do I compile the 64 bit version of ECL under Windows with dynamic foreign function support?

For the case that there is no support for the dynamic foreign function interface under Windows, how am I supposed to use CFFI in this environment?

I tried to find an answer in the manual as well as searching with google, but couldn't find any method which would work with the current state of the ECL sources.

Thanks for your help,

Dietrich


By the way, I found some other problems concerning the foreign function interface example files:

A. In ecl/examples/ffi/cffi.lsp

1. rather than using 

#-(or ming32 windows)
(cffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"
  #-darwin "/usr/lib/libm.so")

The option '-lm' should be used.

2. The line

(cffi:defcfun ("sin" c-sin) :double :double)

should read 

(cffi:defcfun ("sin" c-sin) :double '(:double))

3. In

(let ((c-cos (cffi:foreign-funcall "cos" :double 1.0d0 :double)))
   (format t "~%Lisp cos:~t~d~%C cos:~t~d~%Difference:~t~d"
(sin 1.0d0) c-sin (- (sin 1.0d0) c-sin)))

the variable c-cos is defined but c-sin is referred to.

Probably the following was intended:

(let ((c-cos (cffi:foreign-funcall "cos" :double 1.0d0 :double)))
   (format t "~%Lisp cos:~t~d~%C cos:~t~d~%Difference:~t~d"
(cos 1.0d0) c-cos (- (cos 1.0d0) c-cos)))

B. In file ecl/examples/ffi/uffi.lsp

Here again: rather than

#-(or ming32 windows)
(cffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"
   #-darwin "/usr/lib/libm.so")

The option '-lm' should be used



------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ecls-list mailing list
Ecls-list@...
https://lists.sourceforge.net/lists/listinfo/ecls-list
Jason Sewall | 17 May 2013 00:09
Picon

Function type proclaimations not working?

The docs (III 4.4) give an example for optimizing code based on type
info (which seems to be missing a close paren, by the way):

(eval-when (compile)
  (proclaim '(function tak (fixnum fixnum fixnum) fixnum)))

(defun tak (x y z)
  (declare (fixnum x y z))
  (if (not (< y x))
      z
      (tak (tak (1- x) y z)
       (tak (1- y) z x)
       (tak (1- z) x y))))

ECL 13.4.1 (from HEAD built a few weeks ago) complains "Warning: The
variable name (FIXNUM FIXNUM FIXNUM) is not a symbol."

The resulting c file does not look anything like the example. Did some
behavior change/go away? Even if I add (proclaim '(optimize (speed 3)
(safety 0))), lots of type info doesn't get propagated.

If this is my fault for running things off of HEAD, please tell me to
shut up and I'll do so. Let me know if I can help, too.

Cheers,
Jason

P.S. Here's the C file (or the first part of it, anyway) if I add the
optimize directive to the above:
/*    Compiler: ECL 13.4.1                                          */
/*    Date: 2013/5/16 16:00 (yyyy/mm/dd)                            */
/*    Machine: Linux 3.8.7-201.fc18.x86_64 x86_64                   */
/*    Source: var.lisp                                              */
#include <ecl/ecl-cmp.h>
#include "var.eclh"
/*    function definition for TAK                                   */
/*    optimize speed 3, debug 0, space 0, safety 0                  */
static cl_object L1tak(cl_object v1x, cl_object v2y, cl_object v3z)
{
 cl_object T0;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 cl_fixnum v4x;
 cl_fixnum v5y;
 cl_fixnum v6z;
 v4x = ecl_fixnum(v1x);
 v5y = ecl_fixnum(v2y);
 v6z = ecl_fixnum(v3z);
TTL:
 if ((v5y)<(v4x)) { goto L1; }
 value0 = ecl_make_fixnum(v6z);
 cl_env_copy->nvalues = 1;
 return value0;
L1:;
 {
  cl_fixnum v7;
  T0 = ecl_make_integer((v4x)-1);
  v7 = ecl_fixnum(L1tak(T0, ecl_make_fixnum(v5y), ecl_make_fixnum(v6z)));
  {
   cl_fixnum v8;
   T0 = ecl_make_integer((v5y)-1);
   v8 = ecl_fixnum(L1tak(T0, ecl_make_fixnum(v6z), ecl_make_fixnum(v4x)));
   T0 = ecl_make_integer((v6z)-1);
   v6z = ecl_fixnum(L1tak(T0, ecl_make_fixnum(v4x), ecl_make_fixnum(v5y)));
   v5y = v8;
   v4x = v7;
  }
 }
 goto TTL;
}

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
Ala'a Mohammad | 13 May 2013 12:33
Picon

generated shared library does not contain the defined function

Hi,

This is my first try at ECL, and need help in figuring out what is missing. I had tried googling for similar examples but did not found one that demoed what i wanted.

I'm trying to define a function named sum-array in CL, which is defined in a file called foo.lisp

I compiled foo.lisp, generated foo.o, and then used that to create a shared library libtest.so

Finally I created a C file named try.c that will load libtest.so dynamically, which succeeded, but failed to locate the symbol L1sum_array or demo_sum_array.

I double checked the files and the online resources (docs, and some online tutorials), but couldn't find a clue on what I was missing.

the files and the steps used to compile the example are attached below for reference.

Ala'a

----------------------------------------------------------------------

;; foo.lisp
(defpackage "DEMO"
  (:use :cl)
  (:export "SUM-ARRAY"))

;; using the following
;;;(declaim (si::c-export-fname sum-arary))
;; gave me
;;Unknown declaration specifier SI::C-EXPORT-FNAME
;; so instead I tried 'proclaim', but it seem to have
;; no effect as the generated symbol name is L1sum_array rather than demo_sum_array
(proclaim '(si::c-export-fname sum-arary))

(defun sum-array (array)
  (loop for i from 0 below (length array)
        summing (aref array i)))

----------------------------------------------------------------------


; launch ECL in a console
; ecl -norc
; then execute the following.
;> (compile-file "foo.lisp" :c-file t :h-file t :data-file t :system-p t)
;> (c:build-shared-library "test" :lisp-files '("foo.o"))

----------------------------------------------------------------------

// try.c
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

int main(char **argv, int argc) {
  void * libhandle;
  int (*demo_sum_array)(int[]);
  int nums[10] = {1, 2, 0, 0, 4, 5, 6, 9, 9, 17};

  // Load Shared library
  libhandle = dlopen("./libtest.so",RTLD_NOW);
  if(libhandle==NULL) {
    fprintf(stderr, "Couldn't open library: %s\n",
   dlerror());
    exit(1);
  }

  // summ-array
  ////demo_sum_array  = dlsym(libhandle,"demo_sum_array");
  demo_sum_array  = dlsym(libhandle,"L1sum_array");
  if(demo_sum_array == NULL) {
    /* ERROR HANDLING */
    fprintf(stderr, "%s\n", dlerror());
    exit(1);
  }

  printf("Return is %i\n",(*demo_sum_array)(nums));

  dlclose(libhandle);

  return 0;

}

----------------------------------------------------------------------

: gcc -g try.c -o try -L./ -ltest -ldl

: ./try 
./libtest.so: undefined symbol: L1sum_array

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Ecls-list mailing list
Ecls-list@...
https://lists.sourceforge.net/lists/listinfo/ecls-list
Juan Jose Garcia-Ripoll | 12 May 2013 00:20
Picon
Gravatar

Can you check the Windows builds?

I have spent a stupid month doing things like rebuilding a Windows box that died, trying to install Visual Studio 2012 on top of Window SDK and finding that VS2012 broke everything, finding out what happened with this, and only yesterday did I manage to get something running with Microsoft compilers.

In the process I managed to solve a couple of problems, including a dependency of ECL on the ntwin32.mak (a file which is now absent in Windows SDK). In short, I believe there are now at least the following methods to build ECL

- Visual Studio 2010 Express (standalone) in 32 and 64 bits
- Visual Studio 2012 Express in 32 and 64 bits
- Microsoft SDK 7.1 (actually VS2010 underneath) in 32 and 64 bits
- Mingw32
- Possibly Cygwin (but of little use because of cygwin problems with fork)

Given the fragility of the Windows platform I would appreciate if you could give me a heads up to pack a release.

Juanjo


--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain) 
http://juanjose.garciaripoll.googlepages.com
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Ecls-list mailing list
Ecls-list@...
https://lists.sourceforge.net/lists/listinfo/ecls-list
Jason Sewall | 30 Apr 2013 20:42
Picon

ECL and UIs

I have a C library I have been working on and I'd like to use (Common)
Lisp to write a UI to go on top of it.

I first seized upon ECL for the Lisp, since I could easily make an
interface to the library, and I had a notion at CommonQt might be a
good way to do the UI. Of course, I can put lots of UI material into
the C lib and export that to Lisp myself, but I'd really prefer to
leverage something that already exists.

Leaving the details of the individual hurdles I've come across aside,
I haven't gotten anywhere. It seems like every GUI toolkit for Lisp I
come across is poorly maintained and/or doesn't work with ECL.

I know my way around pure Common Lisp, but I don't have much
experience with libraries for it.

What would you folks do? Does anyone do this? It seems like building
the UI in lisp would be much more flexible and fun than doing it in C!

Cheers,
Jason

P.S. I posted this to /r/lisp in Reddit earlier, but figured this
might be a better place to ask.

P.P.S. I have seen EQL, and it is quite nice, but I am concerned about
it's long-term viability, partially because of its limited development
support and partially because of its heavily vertically integrated
architecture.

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
Matthew Mondor | 26 Apr 2013 11:56

ASDF and *LOAD-VERBOSE*

Hello again,

My apologies if this is not the proper list to ask this, but since it's
an ECL specific ASDF code path:

I noticed that when loading ASDF it now disables *LOAD-VERBOSE* which
usually defaults to T on ECL:

#+ecl
(eval-when (:load-toplevel :compile-toplevel :execute)
  (setf *load-verbose* nil)
  (defun use-ecl-byte-compiler-p () (and (member :ecl-bytecmp *features*) t))
  (unless (use-ecl-byte-compiler-p) (require :cmp)))

This is not a big deal as I can SETF *LOAD-VERBOSE* to T if I
load/REQUIRE ASDF, but it is unexpected.

Will this be a permanent future ASDF change?  If so, could I suggest an
ASDF-specific configuration option for load verbosity?  Or if it's an
ASDF requirement that it be off, shouldn't ASDF instead dynamically
bind it to NIL where needed?

If none of these make sense to ASDF maintainers/integrators then I'll
just SETF the verbosity after loading ASDF from now on, which is
fortunately still possible.

Thanks,
--

-- 
Matt

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
Salvatore Uras | 18 Apr 2013 21:01
Picon

Can't get to build ECL - target mingw32


Hello everybody,
I'm really sorry to bother for such a trivial matter, but I really
can't obtain an ecl build on my windows systems, and I've tried very
many times and with many variations and different options for
configure. I tried an year ago for the first time, and maybe the tenth
time today, but ecl_min can't boot:

;;;
;;; Welcome to bare.lsp. Let's bring this instance up!
;;;
;;;
;;; About to load lsp/load.lsp
;;;
;;; Loading src:lsp;export.lsp
;;; Unhandled lisp initialization error
;;; Message:
FILE-ERROR
;;; Arguments:

Internal or unrecoverable error in:

Lisp initialization error.

I'm sure that this is a well-known, obvious and trivial problem that's
dancing right under my nose, but if someone could spare me some time,
I'd be very thankful.

Cheers,
Salvatore.

--

-- 
Salvatore Uras
Sviluppo software
Via Ruffilli 10
07100 Sassari (SS)
+393470613370
Dietrich Bollmann | 18 Apr 2013 13:43

ERROR caused by FPU control settings...

Hi, 

I would like to integrate ECL into the 3D modelling software

I started with the following minimal code executed from a Rhino plugin:

  char *argv[] = {"Rhinoceros", NULL};
  int argc = sizeof(argv) / sizeof(char*) - 1;
  cl_boot(argc, argv);
  cl_shutdown();

But when loading the plugin I get the following error message:

  Rhinoceros 5.0 RHINO ERROR
  File name: rhino3MathErrorHandling.cpp
  Line number: 256
  Function name: RhMathErrorCheck
  Something has changed the FPU control settings.
  See debugger output window for details.

Any idea how I can avoid this?

Thanks,

Dietrich

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ecls-list mailing list
Ecls-list@...
https://lists.sourceforge.net/lists/listinfo/ecls-list
Dietrich Bollmann | 13 Apr 2013 14:05

Re: Building ECL fails: Debugger received error of type: UNBOUND-VARIABLE, The variable *MODULE-SYMBOLS* is unbound.

[Answering to my own posting]

Hi,

a simple 'git pull' executed today solved the problem...

I am sorry for any inconvenience I may have caused you.

Sincerely,

Dietrich





On Sat, Apr 13, 2013 at 1:08 AM, Dietrich Bollmann <dietrich-55Sq3ERg400gsBAKwltoeQ@public.gmane.org> wrote:
Hi,

I would like to compile ECL on Windows 7 running on my MacBookPro using the Visual Studio Command Prompt (2010) but no ecl.exe is built.

The source code is from the git repository.

Just before giving up, the following error message is printed:

> Debugger received error of type: UNBOUND-VARIABLE
The variable *MODULE-SYMBOLS* is unbound.

Some more context of the output produced by nmake is appended to this email.

Any help is much appreciated!

Thanks, Dietrich


... snip ...
;;; Copying ../src/../contrib/encodings/ISO-2022-JP-1 to build:encodings;ISO-202
2-JP-1#P"c:/Users/dietrich/home/cs/dev/lisp/ecl/src/git/ecl/contrib/encodings/ge
nerate.lisp"
> NIL
> #<two-way stream 054ab6e0>
0
#S(EXT:EXTERNAL-PROCESS :EXT::PID NIL :EXT::INPUT #<output stream "\"rc\" \"/r\"
 \"ecl.rc\""> ...)
> ((#P"SYS:**;*.*.*" #P"c:/Users/dietrich/home/cs/dev/lisp/ecl/src/git/ecl/msvc/
**/*.*"))
> Debugger received error of type: UNBOUND-VARIABLE
The variable *MODULE-SYMBOLS* is unbound.
Error flushed.
> Debugger received error of type: UNBOUND-VARIABLE
The variable *MODULE-FILES* is unbound.
Error flushed.
>       c\cut "~A" "%CD%/package" "~*" ""  " <at> ECL_CFLAGS <at> " "/EHsc /DGC_DLL /DGC_B
UILD /nologo /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /MD /O2 "  " <at> LDFLAGS <at> " "/link /
incremental:no /nologo /nodefaultlib:libcmt /nodefaultlib:libcmtd /nodefaultlib:
libc /nodefaultlib:libcd /nodefaultlib:msvcrtd.lib"  " <at> CLIBS <at> " ""  " <at> libdir <at> " "%
CD%/package"  " <at> includedir <at> " "%CD%/package/ecl"  < util\ecl-config.bat > ecl-con
fig.bat
        c\cut " <at> ECL_CFLAGS <at> " "/EHsc /DGC_DLL /DGC_BUILD /nologo /D_CRT_SECURE_NO
_DEPRECATE /DNDEBUG /MD /O2 "  " <at> LDFLAGS <at> " "/link /incremental:no /nologo /nodef
aultlib:libcmt /nodefaultlib:libcmtd /nodefaultlib:libc /nodefaultlib:libcd /nod
efaultlib:msvcrtd.lib"  " <at> CLIBS <at> " ""  " <at> libdir <at> " "%CD%/package"  " <at> includedir <at> "
"%CD%/package/ecl"  < util\ecl-cc.bat > ecl-cc.bat

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ecls-list mailing list
Ecls-list@...
https://lists.sourceforge.net/lists/listinfo/ecls-list
Zajcev Evgeny | 4 Apr 2013 13:03
Picon

ECL's weak-hash tables


Hello there! Thanks for the excelent software

I'm quite confused about weak hash tables in ECL.

I have simple test program:

.-----[~/tmp/whash.lsp
|  (defvar gg (make-hash-table :weakness :value))
|  
|  (loop repeat 100 do
|    (setf (gethash (gensym) gg)
|          (loop repeat 10 collect (random 100))))
|  
|  #+ecl (format t "Has weak hash: ~A~%" (not (null (member :ecl-weak-hash *features*))))
|  (format t "Before GC: ~A~%" (hash-table-count gg))
|  #+sbcl (sb-ext:gc :full t)
|  #+ecl (si:gc t)
|  (format t "After GC: ~A~%" (hash-table-count gg))
`-----

Its ouput from SBCL

.-----[$ sbcl --script ~/tmp/whash.lsp
|  Before GC: 100
|  After GC: 0
`-----

and from ECL

.-----[$ ecl -shell ~/tmp/whash.lsp
|  Has weak hash: T
|  Before GC: 100
|  After GC: 100
`-----

ECL's results looks a little awkward.  Does weak hash tables really
work in ECL?  Or do I misuse them in some manner?

thanks!

--

-- 
lg

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
Juan Jose Garcia-Ripoll | 2 Apr 2013 23:47
Picon
Gravatar

RC 14.4.1 cancelled

I missed from the logs that ASDF no longer builds on windows: it demands too large a data section.

I will work on that.

My apologies for the false alarm

Juanjo

--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain) 
http://juanjose.garciaripoll.googlepages.com
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Ecls-list mailing list
Ecls-list@...
https://lists.sourceforge.net/lists/listinfo/ecls-list

Gmane