Skip to content

Unable to find SDL on Ubuntu 22.04 #78

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

Open
stuartlangridge opened this issue Sep 9, 2024 · 5 comments
Open

Unable to find SDL on Ubuntu 22.04 #78

stuartlangridge opened this issue Sep 9, 2024 · 5 comments

Comments

@stuartlangridge
Copy link

I tried running https://github.com/littledivy/flappybird on Ubuntu 22.04 with the following result:

18:28 ~/Sc+/flappybird (main) $ ls /usr/lib/x86_64-linux-gnu/libSDL2*
/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.18.2
/usr/lib/x86_64-linux-gnu/libSDL2_image-2.0.so.0
/usr/lib/x86_64-linux-gnu/libSDL2_image-2.0.so.0.2.3
/usr/lib/x86_64-linux-gnu/libSDL2_mixer-2.0.so.0
/usr/lib/x86_64-linux-gnu/libSDL2_mixer-2.0.so.0.2.2
/usr/lib/x86_64-linux-gnu/libSDL2_net-2.0.so.0
/usr/lib/x86_64-linux-gnu/libSDL2_net-2.0.so.0.0.1
/usr/lib/x86_64-linux-gnu/libSDL2_ttf-2.0.so.0
/usr/lib/x86_64-linux-gnu/libSDL2_ttf-2.0.so.0.18.0
18:28 ~/Sc+/flappybird (main) $ uname -a
Linux oz 5.15.0-119-generic #129-Ubuntu SMP Fri Aug 2 19:25:20 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
18:28 ~/Sc+/flappybird (main) $ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy
18:28 ~/Sc+/flappybird (main) $ ./flappybird 
error: Uncaught (in promise) Error: Could not open library: Could not open library: libSDL2.so: cannot open shared object file: No such file or directory
    at new DynamicLibrary (ext:deno_ffi/00_ffi.js:454:42)
    at Object.dlopen (ext:deno_ffi/00_ffi.js:558:10)
    at https://jsr.io/@divy/sdl2/0.12.0/mod.ts:28:19

The deno people suggested in https://fosstodon.org/@deno_land/113108106611366244 that this looks like a bug in this library, and I should file it here, so here it is.

@hakandarama
Copy link

hakandarama commented Oct 29, 2024

I'm using NixOS but, I think that solution could may be the same so I don't want to open another request.

I have a nix shell file like below,

   pkgs.mkShell {
     buildInputs = [
 pkgs.deno
       pkgs.SDL2
       pkgs.rustc
       pkgs.cargo
        pkgs.SDL2_image
        pkgs.gcc
        pkgs.SDL2_ttf
        pkgs.mlocate
        pkgs.findutils
        pkgs.nix-index
     ];
   }

After shell init here is my libraries about SDL2

[sudo] password for interroo: 
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/1000/doc’: Permission denied
/nix/store/jc13yn8zh855il4bkbybpnpisds70mkx-SDL2-2.30.6-dev/include/SDL2
/nix/store/jc13yn8zh855il4bkbybpnpisds70mkx-SDL2-2.30.6-dev/lib/cmake/SDL2
/nix/store/g3dyaid12r0cjq5sqcfjxd3dckbkz63w-nixos/nixos/pkgs/development/libraries/SDL2
/nix/store/lsy6c2f9alj2gkjj36h754kk63x6701l-source/pkgs/development/libraries/SDL2
/nix/store/f9s5ppf6ay05wsviyrn8jb44lbbkb04q-SDL2_sound-2.0.1/include/SDL2
/nix/store/dbp40ny9x8svygk01769g6d12zsj7jq9-nixos/nixos/pkgs/development/libraries/SDL2
/nix/store/vih8vdck628mm1xxnhi1d3rzy68h1yi6-nixos/nixos/pkgs/development/libraries/SDL2
/nix/store/ghg5yhiv547s10rjgiajk60vmavza70w-nixos/nixos/pkgs/development/libraries/SDL2
/nix/store/4yg6mlimzrjcg11jvqv5yb1xdj67c216-SDL2_ttf-2.22.0/include/SDL2
/nix/store/p01c6lmcijvjb3yfnqb8x3hkzxmc4jhz-SDL2_image-2.8.2/include/SDL2
/nix/store/f88l5vi0ms8v52qknpxzdqcs47mc79b0-home-manager-path/include/SDL2
/nix/store/1k4ilbly8y28yja0clq2gm1y0gaji6z9-SDL2_ttf-2.22.0/include/SDL2
/nix/store/yqrq1h81sc6bdz6jlxxipi3qvcld5190-jetbrains-toolbox-2.4.1.32573-fhs/usr/include/SDL2
/nix/store/9j29lw4g9vxlsd0pkz3bw6vf50v48pp0-jetbrains-toolbox-2.4.1.32573-fhs/usr/include/SDL2
/nix/store/qxxg4678zm816k1r3i144gn54z2dw3h3-jetbrains-toolbox-2.4.1.32573-usr-target/include/SDL2
/nix/store/4nrdmbi5gbmlfdsh2mxm74amlk3id3yb-jetbrains-toolbox-2.4.1.32573-fhs/usr/include/SDL2
/nix/store/xfxshsfh47fbqlmymaxzvprgh03fjp1b-SDL2_image-2.8.2/include/SDL2
/nix/store/zqfqxi9zxids52cglw4qqb4rfmj2b914-jetbrains-toolbox-2.4.1.32573-usr-target/include/SDL2
/nix/store/6bklv1fayjcy8bzl63782rzsg73hrz6b-jetbrains-toolbox-2.4.1.32573-usr-target/include/SDL2

And here is sdl2-config output

-I/nix/store/jc13yn8zh855il4bkbybpnpisds70mkx-SDL2-2.30.6-dev/include/SDL2 -I/nix/store/jc13yn8zh855il4bkbybpnpisds70mkx-SDL2-2.30.6-dev/include/SDL2 -I/nix/store/xfxshsfh47fbqlmymaxzvprgh03fjp1b-SDL2_image-2.8.2/include/SDL2 -I/nix/store/4yg6mlimzrjcg11jvqv5yb1xdj67c216-SDL2_ttf-2.22.0/include/SDL2 -I/nix/store/jc13yn8zh855il4bkbybpnpisds70mkx-SDL2-2.30.6-dev/include/SDL2 -I/nix/store/xfxshsfh47fbqlmymaxzvprgh03fjp1b-SDL2_image-2.8.2/include/SDL2 -I/nix/store/4yg6mlimzrjcg11jvqv5yb1xdj67c216-SDL2_ttf-2.22.0/include/SDL2 -D_REENTRANT
-L/nix/store/z9mxzhabjab303ffgpg6szc85rmxc3nx-SDL2-2.30.6/lib -Wl,-rpath,/nix/store/z9mxzhabjab303ffgpg6szc85rmxc3nx-SDL2-2.30.6/lib -Wl,--enable-new-dtags -lSDL2

Btw, I couldn't run demos... And here is my error message

error: Uncaught (in promise) Error: Could not open library: Could not open library: libSDL2.so: cannot open shared object file: No such file or directory
const sdl2 = Deno.dlopen(getLibraryPath("SDL2"), {
                  ^
    at new DynamicLibrary (ext:deno_ffi/00_ffi.js:456:42)
    at Object.dlopen (ext:deno_ffi/00_ffi.js:562:10)
    at https://jsr.io/@divy/sdl2/0.14.0/mod.ts:48:19

Thanks in advance...

@hakandarama
Copy link

hakandarama commented Nov 6, 2024

Well... I just rewrite my shell.nix through README today and sharing

{ pkgs ? import <nixpkgs> {} }:
   pkgs.mkShell {
     buildInputs = [
       	pkgs.deno
       	pkgs.SDL2
	pkgs.SDL2_image
	pkgs.SDL2_ttf
       	pkgs.rustc
       	pkgs.cargo
	pkgs.gcc
	pkgs.mlocate
	pkgs.findutils
	pkgs.nix-index
     ];
     shellHook = ''
	export DENO_SDL2_PATH=/tmp/denosdl
	if [ -d "$DENO_SDL2_PATH" ]; then rm -Rf $DENO_SDL2_PATH; fi
	mkdir $DENO_SDL2_PATH
	ln -s $(nix eval nixpkgs#SDL2.outPath --raw)/lib/libSDL2.so $DENO_SDL2_PATH
	ln -s $(nix eval nixpkgs#SDL2_ttf.outPath --raw)/lib/libSDL2_ttf.so $DENO_SDL2_PATH
	ln -s $(nix eval nixpkgs#SDL2_image.outPath --raw)/lib/libSDL2_image.so $DENO_SDL2_PATH
     '';
}

Hope this helps somebody....

@hmleal
Copy link

hmleal commented Mar 1, 2025

Hello @stuartlangridge, I hope you are still trying to run the flappybird game ^^

Basead on your log uou can easily just do something like this:

DENO_SDL2_PATH=/usr/lib/x86_64-linux-gnu/ deno run examples/hello.ts from the root folder

This library from some reason expects the SDL2_PATH to be config up front instead of searching for it inside of the OS

You can see more details here: https://github.com/littledivy/deno_sdl2/blob/main/mod.ts#L13

@hmleal
Copy link

hmleal commented Mar 1, 2025

@littledivy Can we fix the try/catch to in case DENO_SDL2_PATH search it inside of the OS? Or at least insert a better message?

https://github.com/littledivy/deno_sdl2/blob/main/mod.ts#L17C3-L17C59

I can work on the PR, thanks in advance

@stuartlangridge
Copy link
Author

Basead on your log uou can easily just do something like this:
DENO_SDL2_PATH=/usr/lib/x86_64-linux-gnu/ deno run examples/hello.ts from the root folder
This library from some reason expects the SDL2_PATH to be config up front instead of searching for it inside of the OS

Sadly this doesn't seem to work, still, although it's closer:

$ DENO_SDL2_PATH=/usr/lib/x86_64-linux-gnu deno run --allow-env --allow-ffi main.js 
error: Uncaught (in promise) Error: Could not open library: Could not open library: /usr/lib/x86_64-linux-gnu/libSDL2.so: cannot open shared object file: No such file or directory
const sdl2 = Deno.dlopen(getLibraryPath("SDL2"), {
                  ^
    at new DynamicLibrary (ext:deno_ffi/00_ffi.js:456:42)
    at Object.dlopen (ext:deno_ffi/00_ffi.js:562:10)
    at https://jsr.io/@divy/sdl2/0.12.0/mod.ts:47:19

and this is because it seems to be looking for /usr/lib/x86_64-linux-gnu/libSDL2.so whereas what actually exists is /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.

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

3 participants