Open Smurfy98 opened 1 month ago
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")
.
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: