compile error common lisp - common-lisp

I am trying to compile "my-project" common-lisp,
this is the relevant sections, which breaks while compiling:
(ql:quickload :cffi-grovel)
(ql:quickload :static-vectors)
Compile Messages
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:PREPARE-OP >
#<ASDF/SYSTEM:SYSTEM "static-vectors">)
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:PREPARE-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "pkgdcl">)
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:COMPILE-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "pkgdcl">)
..........................
[package static-vectors] 2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:LOAD-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "pkgdcl">)
2: ASDF/ACTION:PERFORM returned T
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:PREPARE-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "constantp">)
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:COMPILE-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "constantp">)
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:LOAD-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "constantp">)
2: ASDF/ACTION:PERFORM returned T
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:PREPARE-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "initialize">)
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:COMPILE-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "initialize">)
. 2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:LOAD-OP >
#<ASDF/LISP-ACTION:CL-SOURCE-FILE
"static-vectors" "initialize">)
2: ASDF/ACTION:PERFORM returned T
2: (ASDF/ACTION:PERFORM #<ASDF/LISP-ACTION:PREPARE-OP >
#<CFFI-GROVEL:GROVEL-FILE
"static-vectors" "ffi-types">)
2: ASDF/ACTION:PERFORM returned NIL
2: (ASDF/ACTION:PERFORM #<CFFI-GROVEL::PROCESS-OP >
#<CFFI-GROVEL:GROVEL-FILE
"static-vectors" "ffi-types">)
; cc -m64 -o /home/me/.cache/common-lisp/sbcl-1.3.1.debian-linux-x64/home /me/.dotfiles/sbcl/.quicklisp/dists/quicklisp/software/static-vectors-1.6/src/ffi-types__grovel-tmpOU81XRV0 -I/home/me/.dotfiles/sbcl/.quicklisp/dists/quicklisp/software/cffi_0.17.1/ /home/me/.cache/common-lisp/sbcl-1.3.1.debian-linux-x64/home/me/.dotfiles/sbcl/.quicklisp/dists/quicklisp/software/static-vectors-1.6/src/ffi-types__grovel.c
3: (RUN-PROGRAM "cc" ("-m64" "-o" "/home/me/.cache/common-lisp/sbcl-1.3.1.debian-linux-x64/home/me/.dotfiles/sbcl/.quicklisp/dists/quicklisp/software/static-vectors-1.6/src/ffi-types__grovel-tmpOU81XRV0" "-I/home/me/.dotfiles/sbcl/.quicklisp/dists/quicklisp/software/cffi_0.17.1/" "/home/me/.cache/common-lisp/sbcl-1.3.1.debian-linux-x64/home/me/.dotfiles/sbcl/.quicklisp/dists/quicklisp/software/static-vectors-1.6/src/ffi-types__grovel.c") :INPUT T :OUTPUT T :ERROR T :WAIT T :ALLOW-OTHER-KEYS T :IF-INPUT-DOES-NOT-EXIST :ERROR :IF-OUTPUT-EXISTS :OVERWRITE :IF-ERROR-EXISTS :OVERWRITE :SEARCH T :IF-OUTPUT-DOES-NOT-EXIST :CREATE :IF-ERROR-DOES-NOT-EXIST :CREATE :WAIT T :INPUT :INTERACTIVE :OUTPUT :INTERACTIVE :ERROR-OUTPUT :INTERACTIVE :INPUT :INTERACTIVE :ERROR-OUTPUT :INTERACTIVE :IF-INPUT-DOES-NOT-EXIST :ERROR :IF-OUTPUT-EXISTS :OVERWRITE :IF-ERROR-OUTPUT-EXISTS :OVERWRITE :ELEMENT-TYPE :DEFAULT :EXTERNAL-FORMAT :UTF-8 :OUTPUT :INTERACTIVE :ERROR-OUTPUT :INTERACTIVE)
strange behavior:
My floating x-terminal-emulator-window (X11, i3-Window-Manager) is popping up to the front! I have to kill this window, to get the compile process going on, but after that it lands directly in the DEBUGGER,
with following condition:
Error/Debugger
#<error printing object> cannot be printed readably.
[Condition of type CFFI-GROVEL:GROVEL-ERROR]
Restarts:
0: [RETRY] Retry PROCESS-OP on #<GROVEL-FILE "static-vectors" "ffi-types">.
1: [ACCEPT] Continue, treating PROCESS-OP on #<GROVEL-FILE "static-vectors" "ffi-types"> as having been successful.
2: [RETRY] Retry ASDF operation.
3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration.
4: [ABORT] Give up on "my-project"
5: [RETRY] Retry EVAL of current toplevel form.
--more--
Backtrace:
0: (CFFI-GROVEL:GROVEL-ERROR "~a" #<PRINT-NOT-READABLE {100E16CC53}>)
1: ((LAMBDA NIL :IN CFFI-GROVEL:PROCESS-GROVEL-FILE))
2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN CFFI-GROVEL:PROCESS-GROVEL-FILE) {100AEB197B}>)
3: ((:METHOD ASDF/ACTION:PERFORM (CFFI-GROVEL::PROCESS-OP CFFI-GROVEL:GROVEL-FILE)) #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "static-vectors" "ffi-types">) [fast-method]
4: ((SB-PCL::EMF ASDF/ACTION:PERFORM) #<unavailable argument> #<unavailable argument> #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "static-vectors" "ffi-types">)
5: (SB-DEBUG::TRACE-CALL #<SB-DEBUG::TRACE-INFO ASDF/ACTION:PERFORM> #<CLOSURE (LAMBDA (SB-PCL::.ARG0. SB-PCL::.ARG1.) :IN "/build/sbcl-X2E_zI/sbcl-1.3.1/src/pcl/dlisp3.fasl") {10053FF57B}> #<CFFI-GROVEL..
6: ((:METHOD ASDF/ACTION:PERFORM-WITH-RESTARTS :AROUND (T T)) #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "static-vectors" "ffi-types">) [fast-method]
7: ((:METHOD ASDF/PLAN:PERFORM-PLAN (LIST)) ((#<ASDF/LISP-ACTION:PREPARE-OP > . #1=#<ASDF/SYSTEM:SYSTEM "uiop">) (#2=#<ASDF/LISP-ACTION:COMPILE-OP > . #1#) (#3=#<ASDF/LISP-ACTION:LOAD-OP > . #1#) (#<CFFI..
8: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
9: ((:METHOD ASDF/PLAN:PERFORM-PLAN :AROUND (T)) ((#<ASDF/LISP-ACTION:PREPARE-OP > . #1=#<ASDF/SYSTEM:SYSTEM "uiop">) (#2=#<ASDF/LISP-ACTION:COMPILE-OP > . #1#) (#3=#<ASDF/LISP-ACTION:LOAD-OP > . #1#) (#..
10: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
After "ACCEPT"ing the condition and treating PROCESS-OP on # as having been successful, the compile process goes on, followed by a simple error, because the compiled fasl-file couldn't be found.
Troubleshoot
After being confused about such a side effect on my local SBCL+SLIME setup, i tried
1.) delete $HOME/.cache/common-lisp/ and re-compile, without success or change.
2.) installing a fresh environment via Roswell and run from there,
which gave me the same error, plus a terminal-warning, which may shed some light on the problem:
** (x-terminal-emulator:27111): WARNING **: Binding '<Shift><Control><Alt>a' failed!
Unable to bind hide_window key, another instance/window has it.
PluginRegistry::load_plugins: Importing plugin __init__.py failed: 'module' object has no attribute 'AVAILABLE'
I am not sure, if and how these occurences depend on each other,
so how can i start to fix this window behavior?
How could I proceed to compile the failed components?

The error has been circumvented - although executing the pure RUN-PROGRAM throws the same error on my system - by following the guideline of ASDF 3 in Appendix D
As an example use, the proper way to use the CFFI library is to use :defsystem-depends-on ("cffi-grovel") as below, which defines the class asdf::cffi-grovel, that can be designated by the keyword :cffi-grovel amongst the components of the system:
(defsystem "some-system-using-ffi"
:defsystem-depends-on ("cffi-grovel")
:depends-on ("cffi")
:components
((:cffi-grovel "foreign-functions")
...))
After inserting this in my-project.asd, there compile error has been gone.

Related

RStan toolchain error on ubuntu

I installed RStan, had a problem, uninstalled it, and then tried reinstalling it using https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Mac-or-Linux
However, when I try using rstan, I get this error:
Error in library(rstan) : there is no package called ‘rstan’
I noticed when I run the toolchain diagnostic mentioned on the above page,
fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )
fx( 2L, 5 ) # should be 10
I get an error:
clang: warning: argument unused during compilation: '-arch x86_64'
clang: warning: argument unused during compilation: '-arch x86_64'
file16777e2261ec.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [file16777e2261ec.so] Error 1
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern "C" {
13: SEXP file16777e2261ec( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file16777e2261ec( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning("your C++ program does not return anything");
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! clang: warning: argument unused during compilation: '-arch x86_64'
clang: warning: argument unused during compilation: '-arch x86_64'
file16777e2261ec.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [file16777e2261ec.so] Error 1
In addition: Warning message:
running command '/usr/lib/R/bin/R CMD SHLIB file16777e2261ec.cpp 2> file16777e2261ec.cpp.err.txt' had status 1
Error in fx(2L, 5) : could not find function "fx"
What is going wrong? Thank you!

Using trace with functions not defined by me

I'm using sbcl 1.4.6 and I have this behaviour:
* (trace string<)
(STRING<)
* (string< "hola" "pato")
0: (STRING< "hola" "pato")
0: STRING< returned 0
0
* (defun test-without-cond (str)
(string< "hola" str))
TEST-WITHOUT-COND
* (test-without-cond "pato")
0
If the function is allready defined in common lisp, I cannot use trace when using inside a user defined function. BUt this is not a problem if I define the function
* (defun my-string< (str) (string< str "hello"))
MY-STRING<
* (trace my-string<)
(MY-STRING<)
* (defun test-2 (str) (my-string< str))
TEST-2
* (test-2 "gato")
0: (MY-STRING< "gato")
0: MY-STRING< returned 0
0
Why is this happening?
What can be traced depends on the implementation and various settings.
For SBCL read the manual: Open Coding and Inline Expansion
But SBCL now also has an interpreter and it looks like you can trace calls to CL functions from interpreted code:
* (setf *evaluator-mode* :interpret)
:INTERPRET
* (trace string<)
(STRING<)
* (defun test-without-cond (str)
(string< "hola" str))
TEST-WITHOUT-COND
* (test-without-cond "pato")
0: (STRING< "hola" "pato")
0: STRING< returned 0
0
*
Note that one might need to be careful with tracing core functions, since they can be called a lot...

What's the difference between count and length?

For example in Scheme (count '(1 2 3)) gives 3 and (length '(1 2 3)) also gives 3.
It depends on what interpreter you're using. In standard Scheme, only length is defined. In other interpreters (say, Racket) count exists but it's different, it receives a list and a predicate and returns the number of elements in the list that meet the condition.
I don't know in which interpreter count is defined as a single-parameter function that returns the length of the list, (In Racket (count '(1 2 3)) causes an error), but it seems to me that count is just an alias for length in your interpreter (in other words: they're the same thing) - to be sure, please check the documentation. If I had to choose one, I'd use length, which is standard and will work everywhere.
length returns the number of elements in a list.
count is not a standard procedure mentioned in any of the official Scheme reports (I searched R5RS, R6RS and R7RS) so it's not a part of Scheme. In many implementations you will get some sort of error saying that count does not exist. This is radically different than the expected result you have in your question but it is the more likely result if you were to test it in 5 Scheme implementations.
There is no reason to use a implementation dependent extension when its result is the same as length.
I have tried (count '(1 2 3)) in stalin (r4rs), scm (r5rs), chicken (r5rs), gambit (r5rs), racket (both r5rs and r6rs), ikarus (r6rs), chibi-scheme (r7rs), gauche/gosh (r7rs). None of them have count.
sylwester#pussycat:/p/n/sylwester$ csi
CHICKEN
(c) 2008-2013, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.8.0.5 (stability/4.8.0) (rev 5bd53ac)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2013-10-03 on aeryn.xorinia.dim (Darwin)
#;1> (count '(1 2 3))
Error: unbound variable: count
Call history:
<syntax> (count (quote (1 2 3)))
<syntax> (quote (1 2 3))
<syntax> (##core#quote (1 2 3))
<eval> (count (quote (1 2 3))) <--
#;1>
sylwester#pussycat:/p/n/sylwester$ gsi
Gambit v4.6.9
> (count '(1 2 3))
*** ERROR IN ##raise-unbound-global-exception -- Unbound variable: count
1>
>
*** EOF again to exit
sylwester#pussycat:/p/n/sylwester$ ikarus
Ikarus Scheme version 0.0.4-rc1+, 64-bit (revision 1870, build 2012-02-21)
Copyright (c) 2006-2009 Abdulaziz Ghuloum
> (count '(1 2 3))
Unhandled exception
Condition components:
1. &undefined
2. &who: eval
3. &message: "unbound variable"
4. &irritants: (count)
>
sylwester#pussycat:/p/n/sylwester$ plt-r5rs
Welcome to Racket v6.1.1.
R5RS legacy support loaded
> (count '(1 2 3))
count: undefined;
cannot reference undefined identifier
context...:
/usr/share/racket/collects/racket/private/misc.rkt:87:7
/usr/share/racket/pkgs/r5rs-lib/r5rs/run.rkt: [running body]
sylwester#pussycat:/p/n/sylwester$ echo "(import (rnrs))
(display (count '(1 2 3)))" > test.scm
sylwester#pussycat:/p/n/sylwester$ plt-r6rs test.scm
test.scm:2:10: count: unbound identifier in module
in: count
context...:
/usr/share/racket/pkgs/r6rs-lib/r6rs/run.rkt: [running body]
sylwester#pussycat:/p/n/sylwester$ chibi-scheme
> (count '(1 2 3))
ERROR on line 1: undefined variable: count
>
sylwester#pussycat:/p/n/sylwester$
sylwester#pussycat:/p/n/sylwester$ gosh
gosh> (length '(1 2 3))
3
gosh> (count '(1 2 3))
*** ERROR: unbound variable: count
Stack Trace:
_______________________________________
gosh>
sylwester#pussycat:/p/n/sylwester$ scm
SCM version 5e5, Copyright (C) 1990-2006 Free Software Foundation.
SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/lib/scm/Link
;done loading /usr/lib/scm/Link.scm
;loading /usr/lib/scm/Transcen
;done loading /usr/lib/scm/Transcen.scm
> (count '(1 2 3))
;ERROR: "/usr/lib/scm/Iedline.scm": unbound variable: count
; in expression: (count (quote (1 2 3)))
; in top level environment.
;STACK TRACE
1; (##let ((tail (##lambda (c) (##if (##char? ##c) ##c (##let* (( ...
2; (count (quote (1 2 3)))
>
sylwester#pussycat:/p/n/sylwester$ echo "(display (count '(1 2 3)))" > test.scm
sylwester#pussycat:/p/n/sylwester$ stalin -On test.scm
test.scm:1:10:Unbound variable

{ returning a string from a function } EVAL: variable has no value

I'm unable to print the return value of return-str.
; return-str.lisp
(defun ask-for-input(str)
(princ str)
(let ((cmd (read-line)))
cmd))
(defun return-str()
(let ((data-str (ask-for-input "enter a string")))
(data-str)))
(princ return-str)
Executing the code above with clisp, I got:
$ clisp return-str.lisp
*** - EVAL: variable RETURN-STR has no value
Please help me on how to properly return a string from return-str.
Thank you.
Your parentheses are incorrect in a couple of places.
(data-str) should be replaced with data-str because data-str is not a function.
(princ return-str) should be replaced with (princ (return-str)) because return-str is a function.

issue with cxxfunction of package inline

I was trying to run the colMaxRCpp function provided by Dirk Eddelbuettel in this post. I'm just repeating the function here so that folks reading this post don't have to click on the link.
library(inline)
colMaxRcpp <- cxxfunction(signature(X_="numeric"), plugin="Rcpp", body='
Rcpp::NumericMatrix X(X_);
int n = X.ncol();
Rcpp::NumericVector V(n);
for (int i=0; i<n; i++) {
Rcpp::NumericVector W = X.column(i);
V[i] = *std::max_element(W.begin(), W.end()); // from the STL
}
return(V);
')
When I tried to run it, I got the following error:
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
file148253859d1.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in
make: *** [file148253859d1.o] Error 1
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1:
2: // includes from the plugin
3:
4: #include <Rcpp.h>
5:
6:
7: #ifndef BEGIN_RCPP
8: #define BEGIN_RCPP
9: #endif
10:
11: #ifndef END_RCPP
12: #define END_RCPP
13: #endif
14:
15: using namespace Rcpp;
16:
17:
18: // user includes
19:
20:
21: // declarations
22: extern "C" {
23: SEXP file148253859d1( SEXP X_) ;
24: }
25:
26: // definition
27:
28: SEXP file148253859d1( SEXP X_ ){
29: BEGIN_RCPP
30:
31: Rcpp::NumericMatrix X(X_);
32: int n = X.ncol();
33: Rcpp::NumericVector V(n);
34: for (int i=0;i<n; i++) {
35: Rcpp::NumericVector W=X.column(i);
36: V[i] = *std::max_element(W.begin(),W.end());
37: }
38: return(V);
39:
40: END_RCPP
41: }
42:
43:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
file148253859d1.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in
make: *** [file148253859d1.o] Error 1
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file148253859d1.cpp 2>
file148253859d1.cpp.err.txt' had status 1
I can't understand the error message above. What can I do to fix this error? Thanks.
EDIT:
This is the error if I try evalCpp("2+2")
g++ -m64 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG -I"C:/Users/Pradipto/Documents/R/win- library/3.0/Rcpp/include" -I"C:/Users/Pradipto/Documents/R/win-library/3.0/Rcpp/include"
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c
file1bb87b48650d.cpp -o file1bb87b48650d.o file1bb87b48650d.cpp:1:0: sorry, unimplemented: 64- bit mode not compiled in make: *** [file1bb87b48650d.o] Error 1
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
It's not an issue with the code. Using Rcpp-as-released:
R> source("/tmp/uday.R") ## with your example in this file
R> colMaxRcpp(matrix(1:9,3))
[1] 3 6 9
R>
Try something simpler such as
R> evalCpp("2 + 2") ## eval expression via C++ program
[1] 4
R> evalCpp("M_PI") ## pi as constant in math.h
[1] 3.14159
R>
to see that your compiler is fine.

Resources