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

M1 mac + sdl2 error #154

Open
t-my opened this issue Aug 9, 2022 · 29 comments
Open

M1 mac + sdl2 error #154

t-my opened this issue Aug 9, 2022 · 29 comments

Comments

@t-my
Copy link

t-my commented Aug 9, 2022

After installing sdl2 (brew install sdl2 and manual download), I'm trying to load sdl2:

To load "sdl2":
  Load 1 ASDF system:
    sdl2
; Loading "sdl2"
................; Note: skipping function C-MALLOC (nee "malloc") due to parameter SIZE of type
; SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-CALLOC (nee "calloc") due to parameter NMEMB of
; type SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-REALLOC (nee "realloc") due to parameter SIZE of
; type SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-MEMSET (nee "memset") due to parameter N of type
; SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-MEMCPY (nee "memcpy") due to parameter N of type
; SIZE-T due to undefined foreign type: SIZE-T
....
; file: /Users/tuomas-matti.soikkel/quicklisp/dists/quicklisp/software/cl-sdl2-20220707-git/src/autowrap.lisp
; in: AUTOWRAP:C-INCLUDE '(SDL2 AUTOWRAP-SPEC "SDL2.h")
;     (AUTOWRAP:C-INCLUDE '(SDL2-FFI::SDL2 SDL2-FFI::AUTOWRAP-SPEC "SDL2.h")
;                         :ACCESSOR-PACKAGE :SDL2-FFI.ACCESSORS :FUNCTION-PACKAGE
;                         :SDL2-FFI.FUNCTIONS :SPEC-PATH
;                         '(SDL2-FFI::SDL2 SDL2-FFI::AUTOWRAP-SPEC)
;                         :EXCLUDE-SOURCES
;                         ("/usr/local/lib/clang/([^/]*)/include/(?!stddef.h)"
;                          "/usr/include/" "/usr/include/arm-linux-gnueabihf"
;                          "/usr/include/X11/")
;                         :INCLUDE-SOURCES
;                         ("stdint.h" "bits/types.h" "sys/types.h" "bits/stdint"
;                          "machine/_types.h" "SDL2")
;                         ...)
;
; caught COMMON-LISP:ERROR:
;   (during macroexpansion of (AUTOWRAP:C-INCLUDE '(SDL2 AUTOWRAP-SPEC ...) ...))
;   Couldn't execute "c2ffi": No such file or directory

debugger invoked on a UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {70086C0C63}>:
  COMPILE-FILE-ERROR while compiling #<CL-SOURCE-FILE "sdl2" "autowrap">

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY                        ] Retry
                                     compiling #<CL-SOURCE-FILE "sdl2" "autowrap">.
  1: [ACCEPT                       ] Continue, treating
                                     compiling #<CL-SOURCE-FILE "sdl2" "autowrap">
                                     as having been successful.
  2:                                 Retry ASDF operation.
  3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
                                     configuration.
  4:                                 Retry ASDF operation.
  5:                                 Retry ASDF operation after resetting the
                                     configuration.
  6: [ABORT                        ] Give up on "sdl2"
  7: [REGISTER-LOCAL-PROJECTS      ] Register local projects and try again.
  8:                                 Exit debugger, returning to top level.

(UIOP/LISP-BUILD:CHECK-LISP-COMPILE-RESULTS NIL T T "~/asdf-action::format-action/" ((#<ASDF/LISP-ACTION:COMPILE-OP > . #<ASDF/LISP-ACTION:CL-SOURCE-FILE "sdl2" "autowrap">)))
; File has been modified since compilation:
;   SYS:CONTRIB;ASDF;UIOP.LISP.NEWEST
; Using form offset instead of character position.

   source: (ERROR 'COMPILE-FILE-ERROR :CONTEXT-FORMAT CONTEXT-FORMAT
                  :CONTEXT-ARGUMENTS CONTEXT-ARGUMENTS)
0]```

Any hints what could be wrong? Tried to compile c2ffi using [these instructions ](https://github.com/rpav/c2ffi/issues/104) but failed. This worked fine in windows machine.   
@jidibinlin
Copy link

I have this problem too。

@jeongsoolee09
Copy link

I'm having the same problem with Quicklisp installation.

@viniciustozzi
Copy link

I am currently having the same issue as well, I tried on a Mac mini M1 and on a Macbook Pro M1, same issue happens on both devices.

@t-my
Copy link
Author

t-my commented Sep 8, 2022

I did some research and it seems that https://github.com/lispgames/cl-sdl2/tree/main/src/spec folder doesn't have arm-darwin spec files. Is this the issue? How do you generate those?

ping @mfiano

@mfiano
Copy link
Contributor

mfiano commented Sep 8, 2022

Ah, that would explain it. You would need to compile c2ffi and have it in your path, delete the spec files, and then load cl-sdl2 and it will generate them all. If it does not generate them for your architecture, then a small code change is needed, which I am not sure how to do as I don't have access to that hardware, and you should ping borodust or rpav.

@t-my
Copy link
Author

t-my commented Sep 8, 2022

Complied c2ffi, it did generate a SDL2.aarch64-apple-darwin9.spec file but the file was empty.

Error message when autloading sdl2:

This is SBCL 2.2.6, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (ql:quickload "sdl2")
To load "sdl2":
  Load 1 ASDF system:
    sdl2
; Loading "sdl2"
................; Note: skipping function C-MALLOC (nee "malloc") due to parameter SIZE of type
; SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-CALLOC (nee "calloc") due to parameter NMEMB of
; type SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-REALLOC (nee "realloc") due to parameter SIZE of
; type SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-MEMSET (nee "memset") due to parameter N of type
; SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-MEMCPY (nee "memcpy") due to parameter N of type
; SIZE-T due to undefined foreign type: SIZE-T
..................................
[package sdl2]....................................
[package sdl2-examples];
; caught ERROR:
;   READ error during COMPILE-FILE:
;
;     Symbol "+SDL-PIXELFORMAT-UNKNOWN+" not found in the SDL2-FFI package.
;
;       Line: 4, Column: 69, File-Position: 106
;
;       Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /Users/tuomas-matti.soikkel/quicklisp/local-projects/cl-sdl2/src/constants.lisp" {7007475EF3}>

debugger invoked on a UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {70086C0C63}>:
  COMPILE-FILE-ERROR while compiling #<CL-SOURCE-FILE "sdl2" "constants">

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY                        ] Retry
                                     compiling #<CL-SOURCE-FILE "sdl2" "constants">.
  1: [ACCEPT                       ] Continue, treating
                                     compiling #<CL-SOURCE-FILE "sdl2" "constants">
                                     as having been successful.
  2:                                 Retry ASDF operation.
  3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
                                     configuration.
  4:                                 Retry ASDF operation.
  5:                                 Retry ASDF operation after resetting the
                                     configuration.
  6: [ABORT                        ] Give up on "sdl2"
  7: [REGISTER-LOCAL-PROJECTS      ] Register local projects and try again.
  8:                                 Exit debugger, returning to top level.

(UIOP/LISP-BUILD:CHECK-LISP-COMPILE-RESULTS NIL T T "~/asdf-action::format-action/" ((#<ASDF/LISP-ACTION:COMPILE-OP > . #<ASDF/LISP-ACTION:CL-SOURCE-FILE "sdl2" "constants">)))
; File has been modified since compilation:
;   SYS:CONTRIB;ASDF;UIOP.LISP.NEWEST
; Using form offset instead of character position.

   source: (ERROR 'COMPILE-FILE-ERROR :CONTEXT-FORMAT CONTEXT-FORMAT
                  :CONTEXT-ARGUMENTS CONTEXT-ARGUMENTS)
0] (quit)
;
; compilation unit aborted
;   caught 2 fatal ERROR conditions
;   caught 1 ERROR condition

@jeongsoolee09
Copy link

FYI: Installing via Quicklisp works on an Intel iMac, so the issue's sure to be Apple-Silicon-specific.

@jidibinlin
Copy link

@jeongsoolee09 Yes. only for apple-sillicon

@t-my
Copy link
Author

t-my commented Sep 9, 2022

Complied c2ffi, it did generate a SDL2.aarch64-apple-darwin9.spec file but the file was empty.

Not sure if I did this the right way, other spec files are empty as well.

@t-my
Copy link
Author

t-my commented Sep 19, 2022

ping @borodust, @rpav could you help us out here?

@borodust
Copy link
Member

I don't have access to apple hardware at the moment - can't help with that platform.

@t-my
Copy link
Author

t-my commented Sep 19, 2022

I could help with the task but would need to have very rudimentary instructions.

@borodust
Copy link
Member

@rpav can have better answers, but you probably need to try to run c2ffi command line (the one cl-sdl2 tries to invoke) directly and see what it outputs - probably some headers are missing or c2ffi couldn't locate them.

@n00p3
Copy link

n00p3 commented Sep 20, 2022

The issue with empty .spec file can be solved by pointing to sdl.h file installed by homebrew instead to the one located in cl-sdl2/src/spec/SDL2.h

CL-USER> (ql:quickload :cl-autowrap)
CL-USER> (autowrap:c-include "/opt/homebrew/include/SDL2/SDL.h")

It will generate files in home directory.
You can see result here: https://gist.github.com/n00p3/552ad992d3ed77dbd2493b9eb637e74d
I tried copying this file to cl-sdl2/src/spec directory and modifying sdl2.asd to include it:

...
  ((:module autowrap-spec
    :pathname "spec"
    :components
    ((:static-file "SDL2.h")
     (:static-file "SDL2.aarch64-apple-darwin9.spec") ; Added this line
...

but it still doesn't solve the issue (see comment section of the attached gist file, there's a lot of errors due to undefined foreign types like uint32 and so on)

btw: if you use cl-autowrap from Quicklisp, you'll get even more errors (rpav/cl-autowrap#119), clone master branch directly from GitHub instead.

@n00p3
Copy link

n00p3 commented Sep 21, 2022

I managed to get rid of the Symbol "+SDL-PIXELFORMAT-UNKNOWN+" not found in the SDL2-FFI package. by modifying autowrap.lisp file and adding the following to :sysincludes

(cl:list "/opt/homebrew/include/"
         "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/"
         "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
         "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Headers")

But now I'm getting different errors 😓

CL-USER> (ql:quickload :sdl2)
To load "sdl2":
  Load 1 ASDF system:
    sdl2
; Loading "sdl2"
[package sdl2]....................................
[package sdl2-examples]...........................
.........................................
..

; file: /Users/mg/common-lisp/cl-sdl2/src/sdl2.lisp
; in: DEFUN INIT
;     (SETF SDL2::*LISP-MESSAGE-EVENT* (SDL2-FFI.FUNCTIONS:SDL-REGISTER-EVENTS 1)
;           (PLUS-C:C-REF SDL2::*WAKEUP-EVENT* SDL2-FFI:SDL-EVENT :TYPE)
;             SDL2::*LISP-MESSAGE-EVENT*)
; ==>
;   (SETF (PLUS-C:C-REF SDL2::*WAKEUP-EVENT* SDL2-FFI:SDL-EVENT :TYPE)
;           SDL2::*LISP-MESSAGE-EVENT*)
; 
; caught ERROR:
;   during macroexpansion of (SETF # *LISP-MESSAGE-EVENT*). Use *BREAK-ON-SIGNALS*
;   to intercept.
;   
;    Unknown field :TYPE for foreign-record type:
;   #<AUTOWRAP:FOREIGN-RECORD SDL-EVENT {7009D2D7B3}>
;   Valid fields:
;     :DROP (SDL2-FFI:SDL-DROP-EVENT)
;     :DGESTURE (SDL2-FFI:SDL-DOLLAR-GESTURE-EVENT)
;     :MGESTURE (SDL2-FFI:SDL-MULTI-GESTURE-EVENT)
;     :TFINGER (SDL2-FFI:SDL-TOUCH-FINGER-EVENT)
;     :SYSWM (SDL2-FFI:SDL-SYS-WM-EVENT)
;     :USER (SDL2-FFI:SDL-USER-EVENT)
;     :QUIT (SDL2-FFI:SDL-QUIT-EVENT)
;     :SENSOR (SDL2-FFI:SDL-SENSOR-EVENT)
;     :ADEVICE (SDL2-FFI:SDL-AUDIO-DEVICE-EVENT)
;     :CSENSOR (SDL2-FFI:SDL-CONTROLLER-SENSOR-EVENT)
;     :CTOUCHPAD (SDL2-FFI:SDL-CONTROLLER-TOUCHPAD-EVENT)
;     :CDEVICE (SDL2-FFI:SDL-CONTROLLER-DEVICE-EVENT)
;     :CBUTTON (SDL2-FFI:SDL-CONTROLLER-BUTTON-EVENT)
;     :CAXIS (SDL2-FFI:SDL-CONTROLLER-AXIS-EVENT)
;     :JBATTERY (SDL2-FFI:SDL-JOY-BATTERY-EVENT)
;     :JDEVICE (SDL2-FFI:SDL-JOY-DEVICE-EVENT)
;     :JBUTTON (SDL2-FFI:SDL-JOY-BUTTON-EVENT)
;     :JHAT (SDL2-FFI:SDL-JOY-HAT-EVENT)
;     :JBALL (SDL2-FFI:SDL-JOY-BALL-EVENT)
;     :JAXIS (SDL2-FFI:SDL-JOY-AXIS-EVENT)
;     :WHEEL (SDL2-FFI:SDL-MOUSE-WHEEL-EVENT)
;     :BUTTON (SDL2-FFI:SDL-MOUSE-BUTTON-EVENT)
;     :MOTION (SDL2-FFI:SDL-MOUSE-MOTION-EVENT)
;     :TEXT (SDL2-FFI:SDL-TEXT-INPUT-EVENT)
;     :EDIT-EXT (SDL2-FFI:SDL-TEXT-EDITING-EXT-EVENT)
;     :EDIT (SDL2-FFI:SDL-TEXT-EDITING-EVENT)
;     :KEY (SDL2-FFI:SDL-KEYBOARD-EVENT)
;     :WINDOW (SDL2-FFI:SDL-WINDOW-EVENT)
;     :DISPLAY (SDL2-FFI:SDL-DISPLAY-EVENT)
;     :COMMON (SDL2-FFI:SDL-COMMON-EVENT)
;   

; in: DEFUN VERSION
;     (SDL2::VER :MAJOR)
; 
; caught ERROR:
;   during macroexpansion of (C-REF #:TMP0 SDL2-FFI:SDL-VERSION ...). Use
;   *BREAK-ON-SIGNALS* to intercept.
;   
;    Unknown field :MAJOR for foreign-record type:
;   #<AUTOWRAP:FOREIGN-RECORD SDL-VERSION {7009D2E3B3}>
;   Valid fields:
;   

;     (SDL2::VER :MINOR)
; 
; caught ERROR:
;   during macroexpansion of (C-REF #:TMP0 SDL2-FFI:SDL-VERSION ...). Use
;   *BREAK-ON-SIGNALS* to intercept.
;   
;    Unknown field :MINOR for foreign-record type:
;   #<AUTOWRAP:FOREIGN-RECORD SDL-VERSION {7009D2E3B3}>
;   Valid fields:
;   

;     (SDL2::VER :PATCH)
; 
; caught ERROR:
;   during macroexpansion of (C-REF #:TMP0 SDL2-FFI:SDL-VERSION ...). Use
;   *BREAK-ON-SIGNALS* to intercept.
;   
;    Unknown field :PATCH for foreign-record type:
;   #<AUTOWRAP:FOREIGN-RECORD SDL-VERSION {7009D2E3B3}>
;   Valid fields:
;   
; Debugger entered on #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {700DE46803}>

Looks like it has issues with recognising Uint8/Sint8/Uint16/SInt16 (and so on) types.
I tried replacing every occurrence of these types in SDL2.aarch64-apple-darwin9.spec file
({ "tag": "Sint32" } -> { "tag": ":int", "bit-size": 32, "bit-alignment": 32 } and so on)
and now it throws:

; file: /Users/mg/common-lisp/cl-sdl2/src/surface.lisp
; in: DEFUN GET-COLOR-KEY
;     (PLUS-C:C-LET ((SDL2::KEY SDL2-FFI:UINT32))
;       (SDL2::CHECK-RC
;        (SDL2-FFI.FUNCTIONS:SDL-GET-COLOR-KEY SDL2::SURFACE (SDL2::KEY PLUS-C:&)))
;       SDL2::KEY)
; 
; caught ERROR:
;   during macroexpansion of
;   (C-LET (#)
;     (CHECK-RC #)
;     ...).
;   Use *BREAK-ON-SIGNALS* to intercept.
;   
;    Undefined foreign type: UINT32
.
; in: DEFUN GET-ALPHA-MOD
;     (PLUS-C:C-LET ((SDL2::ALPHA SDL2-FFI:UINT8))
;       (SDL2::CHECK-RC
;        (SDL2-FFI.FUNCTIONS:SDL-GET-SURFACE-ALPHA-MOD SDL2::SURFACE
;                                                      (SDL2::ALPHA PLUS-C:&)))
;       SDL2::ALPHA)
; 
; caught ERROR:
;   during macroexpansion of
;   (C-LET (#)
;     (CHECK-RC #)
;     ...).
;   Use *BREAK-ON-SIGNALS* to intercept.
;   
;    Undefined foreign type: UINT8

; in: DEFUN GET-COLOR-MOD
;     (PLUS-C:C-LET ((SDL2::R SDL2-FFI:UINT8) (SDL2::G SDL2-FFI:UINT8)
;                    (SDL2::B SDL2-FFI:UINT8))
;       (SDL2::CHECK-RC
;        (SDL2-FFI.FUNCTIONS:SDL-GET-SURFACE-COLOR-MOD SDL2::SURFACE
;                                                      (SDL2::R PLUS-C:&)
;                                                      (SDL2::G PLUS-C:&)
;                                                      (SDL2::B PLUS-C:&)))
;       (VALUES SDL2::R SDL2::G SDL2::B))
; 
; caught ERROR:
;   during macroexpansion of
;   (C-LET (# # #)
;     (CHECK-RC #)
;     ...).
;   Use *BREAK-ON-SIGNALS* to intercept.
;   
;    Undefined foreign type: UINT8
; Debugger entered on #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {70143546C3}>
; 
; compilation unit aborted
;   caught 1 fatal ERROR condition
;   caught 3 ERROR conditions

Maybe it will be useful to someone

@ellisvelo
Copy link
Contributor

Here are the modifications that I made to get SDL2 working on an M1 Mac: https://github.com/ellisvelo/cl-sdl2/blob/master/src/autowrap.lisp#L12-L26

The spec file is here: https://github.com/ellisvelo/cl-sdl2/blob/main/src/spec/SDL2.aarch64-apple-darwin9.spec

@mdbergmann
Copy link

mdbergmann commented Oct 15, 2022

Hi.
I'm not sure what I need to do. Can you explain for dummies please?
@ellisvelo , I've cloned your repo, but I'm still seeing:

* (ql:quickload "sdl2")
To load "sdl2":
  Load 1 ASDF system:
    sdl2
; Loading "sdl2"
................; Note: skipping function C-MALLOC (nee "malloc") due to parameter SIZE of type
; SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-CALLOC (nee "calloc") due to parameter NMEMB of
; type SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-REALLOC (nee "realloc") due to parameter SIZE of
; type SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-MEMSET (nee "memset") due to parameter N of type
; SIZE-T due to undefined foreign type: SIZE-T
; Note: skipping function C-MEMCPY (nee "memcpy") due to parameter N of type
; SIZE-T due to undefined foreign type: SIZE-T

as in the original post.
Am I missing something?

@ellisvelo
Copy link
Contributor

ellisvelo commented Oct 16, 2022

Hi @mdbergmann, the latest versions of cffi and cl-autowrap are need to get it to work. I had thought that the latest were already part of the Quicklisp distribution. Here are the steps that I took:

  1. cd ~/quicklisp/local-projects
  2. git clone https://github.com/cffi/cffi.git
  3. git clone https://github.com/rpav/cl-autowrap.git
  4. git clone https://github.com/lispgames/cl-sdl2.git
  5. cd cl-sdl2/src
  6. curl -O https://raw.githubusercontent.com/ellisvelo/cl-sdl2/main/src/autowrap.lisp
  7. cd spec
  8. curl -O https://raw.githubusercontent.com/ellisvelo/cl-sdl2/main/src/spec/SDL2.aarch64-apple-darwin9.spec

@collinalexbell
Copy link

@ellisvelo that seemed to fix it, but now I'm getting The name "PLUS-C" does not designate any package.

@Inc0n
Copy link

Inc0n commented Nov 8, 2022

Thanks! @ellisvelo's comment: #154 (comment), fixed it for me.

@ellisvelo
Copy link
Contributor

@ellisvelo that seemed to fix it, but now I'm getting The name "PLUS-C" does not designate any package.

Hmmm.. not sure @kuberlog because PLUS-C is a part of cl-autowrap. I tried to replicate the error that you are seeing with the recently released November Quicklisp distribution and the SDL2 examples worked without an issue.

@mdbergmann
Copy link

I can confirm it works now for me after repeating the procedure from @ellisvelo

@t-my
Copy link
Author

t-my commented Feb 9, 2023

Thanks guys, got sdl2 working, now trying to load sdl2_ttf with similar errors. Also using sdl2_image Any hints how to fix?

(ql:quickload :sdl2-ttf)

[package trivial-garbage].
; file: /Users/tuomas-matti.soikkel/quicklisp/dists/quicklisp/software/cl-sdl2-ttf-20200925-git/src/autowrap.lisp
; in: AUTOWRAP:C-INCLUDE '(SDL2-TTF AUTOWRAP-SPEC "SDL2_ttf.h")
;     (AUTOWRAP:C-INCLUDE
;      '(SDL2-FFI::SDL2-TTF SDL2-FFI::AUTOWRAP-SPEC "SDL2_ttf.h") :FUNCTION-PACKAGE
;      :SDL2-FFI.FUNCTIONS :SPEC-PATH '(SDL2-FFI::SDL2-TTF SDL2-FFI::AUTOWRAP-SPEC)
;      :EXCLUDE-SOURCES ("/usr/include/") :INCLUDE-SOURCES ("SDL_ttf.h")
;      :SYMBOL-EXCEPTIONS (("SDL_RWops" . "SDL-RWOPS")) ...)
;
; caught COMMON-LISP:ERROR:
;   (during macroexpansion of (AUTOWRAP:C-INCLUDE '(SDL2-TTF AUTOWRAP-SPEC ...) ...))
;   Subprocess #<UIOP/LAUNCH-PROGRAM::PROCESS-INFO {7008FD9AC3}>
;    with command ("c2ffi"
;                  "/Users/tuomas-matti.soikkel/quicklisp/dists/quicklisp/software/cl-sdl2-ttf-20200925-git/src/spec/SDL2_ttf.h"
;                  "-D" "null" "-M"
;                  "/var/folders/s7/g2k04qqj41b4zfx6x5vgl6d14xw_80/T/tmpOPCILR65-tmp.c"
;                  "-A" "aarch64-apple-darwin9")
;    exited with error code 1

debugger invoked on a UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {70052A3A83}>:
  COMPILE-FILE-ERROR while compiling #<CL-SOURCE-FILE "sdl2-ttf" "autowrap">

@ellisvelo
Copy link
Contributor

I ran into that same problem with cl-sdl2-ttf @t-my. I got around it by renaming SDL_ttf.h to SDL2_ttf.h in the quicklisp/dists/quicklisp/software/cl-sdl2-ttf-20200925-git/src/spec directory.

If that doesn't work, then you can try cloning https://github.com/ellisvelo/cl-sdl2-ttf into your quicklisp/local-projects directory.

I didn't run into any issues with cl-sdl2-image and I was able to generate the spec file: https://github.com/ellisvelo/cl-sdl2-image/blob/master/src/spec/SDL_image.aarch64-apple-darwin9.spec

@eliascotto
Copy link

eliascotto commented Jun 10, 2023

I run in a few issues, with cl-sdl2, cl-sdl2-image, cl-sdl2-ttf and solved them following @ellisvelo advices. Working perfectly now on M1.

@LovingSalamander
Copy link

LovingSalamander commented Jun 12, 2023

Following instructions from @ellisvelo works with SBCL, but ECL gives me an error:

CL-USER> (ql:quickload :sdl2)
To load "sdl2":
  Load 1 ASDF system:
    sdl2
; Loading "sdl2"
;;; Error:
;;;   in file autowrap.lisp, position 25
;;;   at (C-INCLUDE '(SDL2 AUTOWRAP-SPEC ...) ...)
;;;   * The macro form (AUTOWRAP:C-INCLUDE '(SDL2 AUTOWRAP-SPEC "SDL2.h") :ACCESSOR-PACKAGE :SDL2-FFI.ACCESSORS :FUNCTION-PACKAGE :SDL2-FFI.FUNCTIONS :SPEC-PATH '(SDL2 AUTOWRAP-SPEC) :EXCLUDE-SOURCES ("/usr/local/lib/clang/([^/]*)/include/(?!stddef.h)" "/usr/include/" "/usr/include/arm-linux-gnueabihf" "/usr/include/X11/") :INCLUDE-SOURCES ("sys/_types/_int8_t.h" "sys/_types/_int16_t.h" "sys/_types/_int32_t.h" "sys/_types/_int64_t.h" "sys/_types/_u_int8_t.h" "sys/_types/_u_int16_t.h" "sys/_types/_u_int32_t.h" "sys/_types/_u_int64_t.h" "sys/_types/_size_t.h" "sys/_types/_wchar_t.h" "_types/_uint8_t.h" "_types/_uint16_t.h" "_types/_uint32_t.h" "_types/_uint64_t.h" "arm/_types.h" "stdint.h" "bits/types.h" "sys/types.h" "bits/stdint" "machine/_types.h" "SDL2") :SYSINCLUDES `,(COMMON-LISP:APPEND (UIOP/UTILITY:SPLIT-STRING (UIOP/OS:GETENV "EXTRA_INCLUDES") :SEPARATOR " ")) :EXCLUDE-DEFINITIONS ("SDL_main" "SDL_LogMessageV" "SDL_vsnprintf" "_inline$" "^_mm_") :INCLUDE-DEFINITIONS ("^XID$" "^Window$" "^Display$" "^_XDisplay$") :SYMBOL-EXCEPTIONS (("SDL_Log" . "SDL-LOGGER") ("SDL_log" . "SDL-LOGN") ("SDL_RWops" . "SDL-RWOPS") ("SDL_GLContext" . "SDL-GLCONTEXT") ("SDL_GLattr" . "SDL-GLATTR") ("SDL_GLprofile" . "SDL-GLPROFILE") ("SDL_GLcontextFlag" . "SDL-GLCONTEXT-FLAG") ("SDL_SysWMinfo" . "SDL-SYSWM-INFO") ("SDL_SysWMmsg" . "SDL-SYSWM-MSG") ("SDL_TRUE" . "TRUE") ("SDL_FALSE" . "FALSE")) :NO-ACCESSORS COMMON-LISP:T :RELEASE-P COMMON-LISP:T) was not expanded successfully.
;;; Error detected:
;;; No spec for #P"/Users/lovingsalamander/quicklisp/local-projects/cl-sdl2/src/spec/SDL2.h" on arch 'arm-apple-darwin9' and c2ffi not found

@ellisvelo
Copy link
Contributor

It's looking for SDL2.arm-apple-darwin9.spec instead of SDL2.aarch64-apple-darwin9.spec @LovingSalamander . I did the following to workaround it.

  1. cp src/spec/SDL2.aarch64-apple-darwin9.spec src/spec/SDL2.arm-apple-darwin9.spec
  2. Remove ~/.cache/common-lisp/ecl-21.2.1-*
  3. ecl
  4. (ql:quickload :sdl2)

@ellisvelo
Copy link
Contributor

@LovingSalamander, the suggestion above works, but I think it would be better to build ecl so that it has the :arm64 and :aarch64 features. I built it using the following command: ./configure --with-gmp-incdir=/opt/homebrew/include --with-gmp-libdir=/opt/homebrew/lib --build aarch64-apple-darwin22.5.0 --host aarch64-apple-darwin22.5.0. I was able to quickload sdl2 after that.

@LovingSalamander
Copy link

@ellisvelo Thank you so much for writing out the full command! I've had trouble building ECL from source and usually resort to homebrew. This was super helpful and I was able to run SDL2 this way.

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

No branches or pull requests