Coder Social home page Coder Social logo

Comments (1)

b3ast-t avatar b3ast-t commented on July 22, 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").

from cl-raylib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.