Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't execute "gcc": The system cannot find the file specified #55

Open
Smurfy98 opened this issue Jun 13, 2024 · 1 comment
Open

Comments

@Smurfy98
Copy link

I am running SBCL on Windows, I have MSYS2 and their UCRT64 GCC installed. Raylib was installed using the raylib installer from their website. I can use GCC from the command line.
Yet when I load cl-raylib (git cloned into local projects and loaded via (ql:quickload :cl-raylib)) the following error message appears:

Couldn't execute "gcc": The system cannot find the file specified.
   [Condition of type CFFI-GROVEL:GROVEL-ERROR]

Restarts:
 0: [RETRY] Retry #<PROCESS-OP > on #<GROVEL-FILE "cffi-libffi" "libffi" "libffi-types">.
 1: [ACCEPT] Continue, treating #<PROCESS-OP > on #<GROVEL-FILE "cffi-libffi" "libffi" "libffi-types"> as having been successful.
 2: [RETRY] Retry ASDF operation.
 3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration.
 4: [RETRY] Retry ASDF operation.
 5: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration.
 6: [ABORT] Give up on "cl-raylib"
 7: [REGISTER-LOCAL-PROJECTS] Register local projects and try again.
 8: [RETRY] Retry SLIME REPL evaluation request.
 9: [*ABORT] Return to SLIME's top level.
 10: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1001940143}>)

Backtrace:
  0: (CFFI-GROVEL:GROVEL-ERROR "~a" #<SIMPLE-ERROR "Couldn't execute ~S: ~A" {1001E49153}>)
  1: ((FLET "THUNK" :IN CFFI-GROVEL:PROCESS-GROVEL-FILE))
  2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<FUNCTION (FLET "THUNK" :IN CFFI-GROVEL:PROCESS-GROVEL-FILE) {5B9DABB}>)
  3: (CFFI-GROVEL:PROCESS-GROVEL-FILE #P"C:/Users/david/quicklisp/dists/quicklisp/software/cffi-20231021-git/libffi/libffi-types.lisp" #P"C:/Users/david/AppData/Local/cache/common-lisp/sbcl-2.3.2-win-x64/C..
  4: ((:METHOD ASDF/ACTION:PERFORM (CFFI-GROVEL::PROCESS-OP CFFI-GROVEL:GROVEL-FILE)) #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "cffi-libffi" "libffi" "libffi-types">) [fast-method]
  5: ((SB-PCL::EMF ASDF/ACTION:PERFORM) #<unused argument> #<unused argument> #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "cffi-libffi" "libffi" "libffi-types">)
  6: ((LAMBDA NIL :IN ASDF/ACTION:CALL-WHILE-VISITING-ACTION))
  7: ((:METHOD ASDF/ACTION:PERFORM :AROUND (CFFI-GROVEL::PROCESS-OP CFFI-GROVEL::CC-FLAGS-MIXIN)) #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "cffi-libffi" "libffi" "libffi-types">) [fast-method]
  8: ((:METHOD ASDF/ACTION:PERFORM-WITH-RESTARTS :AROUND (T T)) #<CFFI-GROVEL::PROCESS-OP > #<CFFI-GROVEL:GROVEL-FILE "cffi-libffi" "libffi" "libffi-types">) [fast-method]
  9: ((:METHOD ASDF/PLAN:PERFORM-PLAN (T)) #<ASDF/PLAN:SEQUENTIAL-PLAN {1001BB3823}>) [fast-method]
 10: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
 11: ((:METHOD ASDF/PLAN:PERFORM-PLAN :AROUND (T)) #<ASDF/PLAN:SEQUENTIAL-PLAN {1001BB3823}>) [fast-method]
 12: ((:METHOD ASDF/OPERATE:OPERATE (ASDF/OPERATION:OPERATION ASDF/COMPONENT:COMPONENT)) #<ASDF/LISP-ACTION:LOAD-OP > #<ASDF/SYSTEM:SYSTEM "cl-raylib"> :PLAN-CLASS NIL :PLAN-OPTIONS NIL) [fast-method]
 13: ((SB-PCL::EMF ASDF/OPERATE:OPERATE) #<unused argument> #<unused argument> #<ASDF/LISP-ACTION:LOAD-OP > #<ASDF/SYSTEM:SYSTEM "cl-raylib"> :VERBOSE NIL)
 14: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
 15: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) #<ASDF/LISP-ACTION:LOAD-OP > #<ASDF/SYSTEM:SYSTEM "cl-raylib"> :VERBOSE NIL) [fast-method]
 16: ((SB-PCL::EMF ASDF/OPERATE:OPERATE) #<unused argument> #<unused argument> ASDF/LISP-ACTION:LOAD-OP "cl-raylib" :VERBOSE NIL)
 17: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
 18: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) ASDF/LISP-ACTION:LOAD-OP "cl-raylib" :VERBOSE NIL) [fast-method]
 19: (ASDF/SESSION:CALL-WITH-ASDF-SESSION #<FUNCTION (LAMBDA NIL :IN ASDF/OPERATE:OPERATE) {1001B9EA3B}> :OVERRIDE T :KEY NIL :OVERRIDE-CACHE T :OVERRIDE-FORCING NIL)
 20: ((LAMBDA NIL :IN ASDF/OPERATE:OPERATE))
 21: (ASDF/SESSION:CALL-WITH-ASDF-SESSION #<FUNCTION (LAMBDA NIL :IN ASDF/OPERATE:OPERATE) {1001B99BAB}> :OVERRIDE NIL :KEY NIL :OVERRIDE-CACHE NIL :OVERRIDE-FORCING NIL)
 22: ((:METHOD ASDF/OPERATE:OPERATE :AROUND (T T)) ASDF/LISP-ACTION:LOAD-OP "cl-raylib" :VERBOSE NIL) [fast-method]
 23: (ASDF/OPERATE:LOAD-SYSTEM "cl-raylib" :VERBOSE NIL)
 24: (QUICKLISP-CLIENT::CALL-WITH-MACROEXPAND-PROGRESS #<FUNCTION (LAMBDA NIL :IN QUICKLISP-CLIENT::APPLY-LOAD-STRATEGY) {1001B9973B}>)
 25: (QUICKLISP-CLIENT::AUTOLOAD-SYSTEM-AND-DEPENDENCIES "cl-raylib" :PROMPT NIL)
 26: ((:METHOD QL-IMPL-UTIL::%CALL-WITH-QUIET-COMPILATION (T T)) #<unused argument> #<FUNCTION (FLET QUICKLISP-CLIENT::QL :IN QUICKLISP-CLIENT:QUICKLOAD) {100196C91B}>) [fast-method]
 27: ((:METHOD QL-IMPL-UTIL::%CALL-WITH-QUIET-COMPILATION :AROUND (QL-IMPL:SBCL T)) #<QL-IMPL:SBCL {1004C68FD3}> #<FUNCTION (FLET QUICKLISP-CLIENT::QL :IN QUICKLISP-CLIENT:QUICKLOAD) {100196C91B}>) [fast-m..
 28: ((:METHOD QUICKLISP-CLIENT:QUICKLOAD (T)) :CL-RAYLIB :PROMPT NIL :SILENT NIL :VERBOSE NIL) [fast-method]
 29: (QL-DIST::CALL-WITH-CONSISTENT-DISTS #<FUNCTION (LAMBDA NIL :IN QUICKLISP-CLIENT:QUICKLOAD) {10019685CB}>)
 30: (SB-INT:SIMPLE-EVAL-IN-LEXENV (QUICKLISP-CLIENT:QUICKLOAD :CL-RAYLIB) #<NULL-LEXENV>)
 31: (EVAL (QUICKLISP-CLIENT:QUICKLOAD :CL-RAYLIB))
 32: (SWANK::EVAL-REGION "(ql:quickload :cl-raylib) ..)
 33: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
 34: (SWANK-REPL::TRACK-PACKAGE #<FUNCTION (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {100196852B}>)
 35: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation request." #<FUNCTION (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {10019684CB}>)
 36: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<FUNCTION (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {10019684AB}>)
 37: (SWANK-REPL::REPL-EVAL "(ql:quickload :cl-raylib) ..)
 38: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK-REPL:LISTENER-EVAL "(ql:quickload :cl-raylib) ..)
 39: (EVAL (SWANK-REPL:LISTENER-EVAL "(ql:quickload :cl-raylib) ..)
 40: (SWANK:EVAL-FOR-EMACS (SWANK-REPL:LISTENER-EVAL "(ql:quickload :cl-raylib) ..)
 41: (SWANK::PROCESS-REQUESTS NIL)
 42: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 43: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 44: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {100196802B}>)
 45: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "c:/Users/david/.emacs.d/.local/straight/build-29.2/slime/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::HAN..
 46: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . #<SWANK/GRAY::SLIME-INPUT-STREAM {1001750D73}>)) #<FUNCTION (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {100196804B}>)
 47: (SWANK::HANDLE-REQUESTS #<SWANK::MULTITHREADED-CONNECTION {100403CC43}> NIL)
 48: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 49: ((FLET "WITHOUT-INTERRUPTS-BODY-138" :IN SB-THREAD::RUN))
 50: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 51: ((FLET "WITHOUT-INTERRUPTS-BODY-131" :IN SB-THREAD::RUN))
 52: (SB-THREAD::RUN)
 53: ("foreign function: #x14003EBE5")
 54: ("foreign function: #x14000685A")
@b3ast-t
Copy link

b3ast-t commented Jul 6, 2024

I had the same problem. I found the solution by going through the cffi code. What you need is to modify c-toolchain.lisp. You will also need to install mingw tools on your WSL (I know there's MSYS2 but i thought it makes more sense to try to use WSL2).

check this patch and see if it makes sense in terms of hardcoded paths i.e. C:/, and /mnt/c/. Change those according to your paths
c-toolchain.patch

on WSL2 you will need to install mingw tools. This should be the starting point before anything else.
sudo apt install mingw-w64

You will then need to download libffi sources and compile them libffi-v3.4.6

wget https://github.com/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz
gzip -d libffi-3.4.6.tar.gz
tar -xf libffi-3.4.6.tar

# the following will not compile (no clue as to why yet. I'm only interested in ffi.h header file)
sh ./configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-dependency-tracking -host=x86_64-w64-mingw32 
# you will find the ffi.h header in the following location
libffi-3.4.6/x86_64-w64-mingw32/include/

From your REPL do the following:

(ql:quickload "str")
(ql:quickload "cffi")
(setf (uiop:getenv "CC") "x86_64-w64-mingw32-gcc")
(ql:quickload "cffi-libffi") <- this will fail. But it has downloaded the files we need.

With the cffi-libffi downloaded, we need to copy some files from libffi compilation to where cffi was downloaded (cffi-libffi is part of that dir)

# copy all contents to c:/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/
cp -r ~/libffi-3.4.6/x86_64-w64-mingw32/include/* /mnt/c/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/

Locate c-toolchain.lisp (mine is in C:/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/toolchain/c-toolchain.lisp)
Apply the patch on that file and attempt to run (ql:quickload "cffi-libffi") again.

Sample output:

; Dedicated output stream setup (port 60565)
; Redirecting all output to this MREPL
; SLY 1.0.43 (#<MREPL mrepl-1-1>)
CL-USER> (setf (uiop:getenv "CC") "x86_64-w64-mingw32-gcc")
0 (0 bits, #x0, #o0, #b0)
CL-USER> (ql:quickload "str")
To load "str":
  Load 1 ASDF system:
    str
; Loading "str"
...
("str")
CL-USER> (ql:quickload "cffi")
To load "cffi":
  Load 1 ASDF system:
    cffi
; Loading "cffi"
.............
("cffi")
CL-USER> (ql:quickload "cffi-libffi")
To load "cffi-libffi":
  Load 1 ASDF system:
    cffi-libffi
; Loading "cffi-libffi"
; pkg-config libffi --cflags
; ERROR: Couldn't execute "pkg-config": The system cannot find the file specified.


; Attempting to continue anyway.
;wsl -e x86_64-w64-mingw32-gcc -o /mnt/c/Users/your-name/AppData/Local/cache/common-lisp/sbcl-2.2.7-win-x64/C/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/libffi/libffi-types__grovel-tmpAAURSO1.obj -c -m64 -I/mnt/c/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/ /mnt/c/Users/your-name/AppData/Local/cache/common-lisp/sbcl-2.2.7-win-x64/C/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/libffi/libffi-types__grovel.c
.;wsl -e x86_64-w64-mingw32-gcc -o /mnt/c/Users/your-name/AppData/Local/cache/common-lisp/sbcl-2.2.7-win-x64/C/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/libffi/libffi-types__grovel-tmpAR3FSGEY.exe -m64 -Wl,--export-dynamic /mnt/c/Users/your-name/AppData/Local/cache/common-lisp/sbcl-2.2.7-win-x64/C/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/libffi/libffi-types__grovel.obj
;"C:\Users\your-name\AppData\Local\cache\common-lisp\sbcl-2.2.7-win-x64\C\Users\your-name\quicklisp\dists\quicklisp\software\cffi-20231021-git\libffi\libffi-types__grovel.exe" C:/Users/your-name/AppData/Local/cache/common-lisp/sbcl-2.2.7-win-x64/C/Users/your-name/quicklisp/dists/quicklisp/software/cffi-20231021-git/libffi/libffi-types__grovel.grovel-tmp.lisp
...
("cffi-libffi")
CL-USER> 

You can now (ql:quickload "cl-raylib").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants