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

Difficulty loading cl-sdl2-mixer with quicklisp #14

Open
NeonFrost opened this issue Nov 12, 2024 · 3 comments
Open

Difficulty loading cl-sdl2-mixer with quicklisp #14

NeonFrost opened this issue Nov 12, 2024 · 3 comments

Comments

@NeonFrost
Copy link

NeonFrost commented Nov 12, 2024

[using SBCL]
(ql:quickload :sdl2-mixer) causes repl to drop to debugger, requiring user input of restart 0, does not happen with sdl2, sdl2-image or sdl2-ttf

restart 0 (reload foreign library) 'fixes' problem, but must be done each time lisp is started (through slime or cli)
info:

 (ql:quickload :sdl2-mixer)
To load "sdl2-mixer":
  Load 5 ASDF systems:
    alexandria asdf cl-autowrap sdl2 trivial-garbage
  Install 1 Quicklisp release:
    cl-sdl2-mixer
; Fetching #<URL "http://beta.quicklisp.org/archive/cl-sdl2-mixer/2024-10-12/cl-sdl2-mixer-20241012-git.tgz">
; 367.28KB
==================================================
376,092 bytes in 0.12 seconds (3139.10KB/sec)
; Loading "sdl2-mixer"
[package sdl2-mixer]
debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD tid=37130 "main thread" RUNNING {1000B88093}>:
  Unable to load any of the alternatives:
   ("libSDL2_mixer-2.0.so.0" "libSDL2_mixer")

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

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY                        ] Try loading the foreign library again.
  1: [USE-VALUE                    ] Use another library instead.
  2: [TRY-RECOMPILING              ] Recompile library and try loading it again
  3: [RETRY                        ] Retry
                                     loading FASL for #<CL-SOURCE-FILE "sdl2-mixer" "library">.
  4: [ACCEPT                       ] Continue, treating
                                     loading FASL for #<CL-SOURCE-FILE "sdl2-mixer" "library">
                                     as having been successful.
  5:                                 Retry ASDF operation.
  6: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
                                     configuration.
  7:                                 Retry ASDF operation.
  8:                                 Retry ASDF operation after resetting the
                                     configuration.
  9: [ABORT                        ] Give up on "sdl2-mixer"
 10: [REGISTER-LOCAL-PROJECTS      ] Register local projects and try again.
 11:                                 Exit debugger, returning to top level.

(CFFI::FL-ERROR "Unable to load any of the alternatives:~%   ~S" ("libSDL2_mixer-2.0.so.0" "libSDL2_mixer"))
   source: (ERROR 'LOAD-FOREIGN-LIBRARY-ERROR :FORMAT-CONTROL CONTROL
                  :FORMAT-ARGUMENTS ARGUMENTS)
0] 0    
.........
(:SDL2-MIXER)
@fitzsim
Copy link
Contributor

fitzsim commented Nov 12, 2024

On Fedora x86-64 I needed sudo dnf install SDL2_mixer. Can you try installing one of the libraries mentioned in the error message ("libSDL2_mixer-2.0.so.0" "libSDL2_mixer")?

@NeonFrost
Copy link
Author

NeonFrost commented Nov 13, 2024

I forgot to mention I'm on Xubuntu 24.04, apologies about that
and the path to SDL2_mixer.h is /usr/include/SDL2/SDL_mixer.h

I've already installed them through the apt package manager

libsdl2-mixer-2.0-0/noble,now 2.8.0+dfsg-1build3 amd64 [installed]

libsdl2-mixer-dev/noble,now 2.8.0+dfsg-1build3 amd64 [installed]

I ran into a similar problem several years ago, and the way I had solved it was by installing the -dev package along with the 2.0 package.

While looking to see if there was anything I could test to make it work, I used the following repo to make sure that sdl2-mixer was able to be called and used
https://github.com/aminosbh/sdl2-mixer-sample

libSDL2_mixer.so, libSDL2_mixer-2.0.so, and libSDL2_mixer-2.0.so.0 are all accessible through /lib/x86_64-linux-gnu on my system

After running through a bunch of different things, I found a problem

in src/library.lisp theres the line:
(:unix (:or "libSDL2_mixer-2.0.so.0" "libSDL2_mixer"))

adding .so onto "libSDL2_mixer" made it so the error didn't pop up, but it seems to affect the rest of the cl-sdl2 system, causing things to not work properly

Running the simple example for cl-sdl2-mixer causes the lisp repl to hang, not even opening a window, which is what happens when I load cl-sdl2-mixer in my own program and try to launch an sdl2 window

After trying that, I tried using the previous release of cl-sdl2-mixer from 2021, however the same exact problem occurred

I think there may be a problem in cl-sdl2, rather than cl-sdl2-mixer

As far as I can tell, when (with-init (:everything) ...) is called, something in cl-sdl2 and cl-sdl2-mixer clashes, but I'm not sure how to proceed with trying to fix it

Edit: I forgot to say, that with my program, even loading cl-sdl2-mixer is enough to cause it to 'hang', even if it's not initialized (well, after with-init is called)

edit 2: If I don't load cl-sdl2-mixer, my program (the tamias game engine) is able to have its default window pop up, but if I load mixer, it hangs

@NeonFrost
Copy link
Author

NeonFrost commented Nov 19, 2024

Hi, I'm not sure if you've been able to, or have had the time to, recreate this problem. I am still having the same issue.

I have: uninstalled and reinstalled libsdl2-mixer using apt (along with the other sdl2 libs), cleared the quicklisp cache, cleared the relevant archives from quicklisp folders, and have tried inserting (and subsequently deleting) simple "This loaded" messages into cffi to see if things aren't getting clobbered, compared cl-sdl2-image and cl-sdl2-mixer code (cl-sdl2-image loads without issue on my system, along with being able to bring an sdl2 window up) to see if removing things would get it to load (and hopefully bring up a window)

None of these worked.

During my attempts at changing things around and seeing what might be the problem, I did find that cffi seems to be handling sdl2-mixer a little differently than sdl2 and sdl2-image.
It seems as though if cffi gets 3 options for library names for sdl2-mixer, it silently fails, loading the third option it receives for the library path, as long as that library exists (e.g. 'libSDL2_mixer.so' will silently fail, but 'libdoesnotexist.so' will send it to debugger)
I did find that the problem is triggered from the line (cffi:use-foreign-library libsdl2-mixer) in src/library.lisp rather than in the define-foreign-library block.

Edit: Forgot to add that this is what the '3 options' thing does:
(ql:quickload :sdl2-mixer) (ql:quickload :sdl2-image) (in-package :cffi) #<PACKAGE "CFFI"> (list-foreign-libraries)
(#<FOREIGN-LIBRARY LIBSDL2-IMAGE "libSDL2_image-2.0.so.0">
#<FOREIGN-LIBRARY LIBSDL2-MIXER "libSDL2_mixer.so">
#<FOREIGN-LIBRARY LIBSDL2 "libSDL2-2.0.so.0">)
the libraries listed (under src/library.lisp)
(:unix (:or "libSDL2_mixer-2.0.so.0" "libSDL2_mixer" "libSDL2_mixer.so")) ;;last one I added
(:unix (:or "libSDL2_image-2.0.so.0" "libSDL2_image" "libSDL2_image.so.1.1"))
(:unix (:or "libSDL2-2.0.so.0" "libSDL2.so.0.2" "libSDL2"))

Thank you to everybody contributing to this project :)

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

2 participants