fccm / OCamlSDL2

OCaml interface to SDL 2.0 (for Linux, Windows, MacOS, and ChromeBook)
Other
51 stars 10 forks source link

In manjaro (arch base linux distro) `sdl2-config --static-libs` returns empty so project cannot be built. #24

Open siabard opened 2 years ago

siabard commented 2 years ago

Using OCamlSDL2 in my manjaro linux box was failed with below message.

(cd _build/default && /usr/bin/ocamlopt.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -o bin/main.exe /home/siabard/.opam/4.13.1/lib/sdl2/sdl2.cmxa -I /home/siabard/.opam/4.13.1/lib/sdl2 /home/siabard/.opam/4.13.1/lib/sdl2_img/sdl2_img.cmxa -I /home/siabard/.opam/4.13.1/lib/sdl2_img lib/sdl2_tutorial.cmxa bin/.main.eobjs/native/dune__exe__Main.cmx)
/usr/bin/ld: /home/siabard/.opam/4.13.1/lib/sdl2/libsdl2_stubs.a(sdljoystick_stub.o): undefined reference to symbol 'SDL_JoystickNumAxes'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib/libSDL2.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking (exit code 1)

In my linux box's sdl2-config, --static-libs is commented.

#    --static-libs)
#    --libs|--static-libs)
#      echo -L/usr/lib -pthread -lSDL2  -lrt -lunwind-generic -lunwind -lglib-2.0 -lgobject-2.0 -lgio-2.0 -libus-1.0 -ldbus-1 -ldl -lm  -Wl,--no-undefined -pthread -lSDL2 
#      ;;

There are two ways tested and they all worked.

  1. Uncomment --static-libs in sdl2-config and install with opam install ocamlsdl2
  2. Get clone of source and modify Makefile as LIBS_ = $(shell sdl2-config --libs) and build it (opam install . in cloned source).

I don't know which way is better, but wish that this will help someone who has a same issue like me.

My /etc/lsb-release is

DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=21.2.1
DISTRIB_CODENAME=Qonos
DISTRIB_DESCRIPTION="Manjaro Linux"

Thank you.

fccm commented 2 years ago

Hi, yes I was not sure what to put as the default, --libs or --static-libs. (My motivation with this binding was to make mini-games and post it on itch.io ; this is why I prefer a static version.)