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

Linux Mint requires installing libsdl2-dev to run freej2me-sdl #35

Open
TwoSpacesSG opened this issue Nov 9, 2024 · 9 comments
Open

Comments

@TwoSpacesSG
Copy link

TwoSpacesSG commented Nov 9, 2024

Otherwise there is this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'SDL2':
libSDL2.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога
libSDL2.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога
Native library (linux-x86-64/libSDL2.so) not found in resource path (freej2me-sdl.jar)
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:325)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:481)
	at io.github.libsdl4j.jna.SdlNativeLibraryLoader.loadLibSDL2(SdlNativeLibraryLoader.java:33)
	at io.github.libsdl4j.jna.SdlNativeLibraryLoader.registerNativeMethods(SdlNativeLibraryLoader.java:24)
	at io.github.libsdl4j.api.Sdl$InternalNativeFunctions.<clinit>(Sdl.java:56)
	at io.github.libsdl4j.api.Sdl.SDL_Init(Sdl.java:30)
	at org.recompile.freej2me.Anbu$SDL.start(Anbu.java:229)
	at org.recompile.freej2me.Anbu.<init>(Anbu.java:181)
	at org.recompile.freej2me.Anbu.main(Anbu.java:76)
	Suppressed: java.lang.UnsatisfiedLinkError: libSDL2.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога
		at com.sun.jna.Native.open(Native Method)
		at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:213)
		... 8 more
	Suppressed: java.lang.UnsatisfiedLinkError: libSDL2.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога
		at com.sun.jna.Native.open(Native Method)
		at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:226)
		... 8 more
	Suppressed: java.io.IOException: Native library (linux-x86-64/libSDL2.so) not found in resource path (freej2me-sdl.jar)
		at com.sun.jna.Native.extractFromResourcePath(Native.java:1141)
		at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:297)
		... 8 more

Ran into this while setting up FJ+ for TASing, and feos asked me to make an issue.

Edit: Also what are the controls on SDL? I only found the arrow keys and 5 that work, no other controls from the AWT frontend that I could find.

@AShiningRay
Copy link
Collaborator

Well, yeah, it's expected that you need sdl's libs installed to run FreeJ2ME's SDL flavor. Though the README documentation doesn't explicitly state that (and wasn't touched when that interface had a major overhaul so its build steps are also out-of-date).

As for controls in SDL, they should be reworked at some point, probably along with the UI.

@vadosnaprimer
Copy link

The unexpected thing is dependency on -dev to launch, which is usually only needed for building. And a normal libsdl2 didn't help (I'll test it on my end asap).

@AShiningRay
Copy link
Collaborator

AShiningRay commented Nov 9, 2024

Which means Mint is running ages-old SDL2 as their default package. current SDL2 is 2.30 (they actually already went to the first SDL3 RC a while ago) whereas the minimum version required by libsdl4j is 2.24... released mid-2022.

Edit: I guess a workaround would be to include an updated libsdl2.so library alongside freej2me-sdl.jar, but that's something that warrants some discussion first, as well as an automated way of doing such inclusion.

@vadosnaprimer
Copy link

vadosnaprimer commented Nov 9, 2024

OK same issue in ubuntu 24.04.

libsdl2-2.0-0/noble,now 2.30.0+dfsg-1build3 amd64 [installed,automatic]
  Simple DirectMedia Layer

Installing libsdl2-dev/noble 2.30.0+dfsg-1build3 fixes it indeed.

I wonder if it's not fixed by sdl itself but by some of its dependencies instead...

In any case, telling people to install libsdl2-dev is fine in itself as long as it makes everything work.

@AShiningRay
Copy link
Collaborator

It's fixed because libsdl4j requires a libsdl2 version equal to, or higher than the one it was built against. Since the oldest libsdl4j available is 2.24.0, that's the oldest we can go on libsdl2. Ideally i'd want users to not even bother with -dev/git packages of any kind, especially on distros like Debian, which will probably take a decade to update SDL2 to 2.24+, so maybe building and shipping a native sdl lib alongside the sdl interface is the best way forward... not sure how that would work for older systems though, despite SDL being VERY portable.

@TwoSpacesSG
Copy link
Author

If I'm understanding this correctly, the -dev package for this is the developer package for people who want to build SDL programs (as mentioned in this amazingly wordy page: https://wiki.libsdl.org/SDL2/Installation ). Hence why it's weird. The normal libsdl2 package is already 2.30 which should be sufficient I guess.

@clementgallet
Copy link

Could it be about missing symlink? The -dev package may add the symlink libSDL2.so pointing to libSDL2-2.0.so.0?

@YoshiRulz
Copy link
Member

If you used an up-to-date version of libsdl4j instead of the oldest version, a copy of the library is bundled in the JAR, which should avoid all such problems.

@AShiningRay
Copy link
Collaborator

Libsdl copies are bundled on all sdl4j versions, although those are only built for a few operating systems and archs, far from all the stuff FreeJ2ME, and SDL, can run on...

Hence why i think building and shipping this lib alongside freej2me-sdl would be the best approach. Bundling every single one of them inside the jar would make it way too heavy and cumbersome.

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

5 participants