2017-04-14 2 views
0

Alors, je voulais utiliser Tsdl et voici ce que je faisais:exception Dl.DL_error: non défini symbole: SDL_GetError

  • Je ne pouvais pas trouver SDL 2.0.5 avec apt-get donc je l'ai téléchargé, ./configure && make && sudo make install
  • opam install tsdl

  • Ensuite, je crée un fichier main.ml (donné à titre d'exemple sur tsdl website):

    open Tsdl 
    open Result 
    
    let main() = match Sdl.init Sdl.Init.video with 
        | Error (`Msg e) -> Sdl.log "Init error: %s" e; exit 1 
        | Ok() -> 
        match Sdl.create_window ~w:640 ~h:480 "SDL OpenGL" Sdl.Window.opengl with 
        | Error (`Msg e) -> Sdl.log "Create window error: %s" e; exit 1 
        | Ok w -> 
         Sdl.delay 3000l; 
         Sdl.destroy_window w; 
         Sdl.quit(); 
         exit 0 
    
    let() = main() 
    
  • ocamlfind ocamlopt -package tsdl -linkpkg -o main.native main.ml

Il travaille et vient maintenant mon problème:

./main.native 
Fatal error: exception Dl.DL_error("./main.native: undefined symbol: SDL_GetError") 

Ai-je fait quelque chose de mal ou dois-je dire explicitement où mon SDL2 lib est ou autre chose?


Mise à jour:

> ocamlobjinfo $(opam config var tsdl:lib)/tsdl.cmxa | grep Extra 
Extra C object files: -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL2 -ltsdl 
Extra C options: 

> sdl2-config --libs 
-L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL2 

Mise à jour 2:

> ldd ./main.native 
    linux-vdso.so.1 => (0x00007fff1f4c1000) 
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f4aff55e000) 
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4aff255000) 
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4aff050000) 
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4afec87000) 
    /lib64/ld-linux-x86-64.so.2 (0x000055dc05e17000) 

Mise à jour 3

[email protected] ~/tsdl $ ocamlfind ocamlopt -cclib -lSDL2 -package tsdl -linkpkg -o min.native min.ml -verbose 

Effective set of compiler predicates: pkg_result,pkg_unix,pkg_bigarray,pkg_str,pkg_bytes,pkg_ctypes,pkg_ctypes.foreign.base,pkg_ctypes.foreign.unthreaded,pkg_ctypes.foreign,pkg_tsdl,autolink,native 
+ ocamlopt.opt -o min.native -verbose -I /home/lhooq/.opam/4.04.0/lib/result -I /home/lhooq/.opam/4.04.0/lib/bytes -I /home/lhooq/.opam/4.04.0/lib/ctypes -I /home/lhooq/.opam/4.04.0/lib/tsdl /home/lhooq/.opam/4.04.0/lib/result/result.cmxa /home/lhooq/.opam/4.04.0/lib/ocaml/unix.cmxa /home/lhooq/.opam/4.04.0/lib/ocaml/bigarray.cmxa /home/lhooq/.opam/4.04.0/lib/ocaml/str.cmxa /home/lhooq/.opam/4.04.0/lib/ctypes/ctypes.cmxa /home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-base.cmxa /home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-unthreaded.cmxa /home/lhooq/.opam/4.04.0/lib/tsdl/tsdl.cmxa -cclib -lSDL2 min.ml 
+ as -o 'min.o' '/tmp/camlasm9ab424.s' 
+ as -o '/tmp/camlstartupe796c9.o' '/tmp/camlstartup4a1081.s' 
+ gcc -o 'min.native' '-L/home/lhooq/.opam/4.04.0/lib/result' '-L/home/lhooq/.opam/4.04.0/lib/bytes' '-L/home/lhooq/.opam/4.04.0/lib/ctypes' '-L/home/lhooq/.opam/4.04.0/lib/tsdl' '-L/home/lhooq/.opam/4.04.0/lib/ocaml' '/tmp/camlstartupe796c9.o' '/home/lhooq/.opam/4.04.0/lib/ocaml/std_exit.o' 'min.o' '/home/lhooq/.opam/4.04.0/lib/tsdl/tsdl.a' '/home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-unthreaded.a' '/home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-base.a' '/home/lhooq/.opam/4.04.0/lib/ctypes/ctypes.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/str.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/bigarray.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/unix.a' '/home/lhooq/.opam/4.04.0/lib/result/result.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/stdlib.a' '-L/usr/local/lib' '-Wl,-rpath,/usr/local/lib' '-Wl,--enable-new-dtags' '-lSDL2' '-ltsdl' '-Wl,--no-as-needed' '-lffi' '-lctypes-foreign-base_stubs' '-Wl,--no-as-needed' '-lffi' '-lctypes_stubs' '-Wl,--no-as-needed' '-lcamlstr' '-lbigarray' '-lunix' '-lSDL2' '/home/lhooq/.opam/4.04.0/lib/ocaml/libasmrun.a' -lm -ldl 

[email protected] ~/tsdl $ ocamlfind ocamlopt -package tsdl -linkpkg -o min.native min.ml -verbose 

Effective set of compiler predicates: pkg_result,pkg_unix,pkg_bigarray,pkg_str,pkg_bytes,pkg_ctypes,pkg_ctypes.foreign.base,pkg_ctypes.foreign.unthreaded,pkg_ctypes.foreign,pkg_tsdl,autolink,native 
+ ocamlopt.opt -o min.native -verbose -I /home/lhooq/.opam/4.04.0/lib/result -I /home/lhooq/.opam/4.04.0/lib/bytes -I /home/lhooq/.opam/4.04.0/lib/ctypes -I /home/lhooq/.opam/4.04.0/lib/tsdl /home/lhooq/.opam/4.04.0/lib/result/result.cmxa /home/lhooq/.opam/4.04.0/lib/ocaml/unix.cmxa /home/lhooq/.opam/4.04.0/lib/ocaml/bigarray.cmxa /home/lhooq/.opam/4.04.0/lib/ocaml/str.cmxa /home/lhooq/.opam/4.04.0/lib/ctypes/ctypes.cmxa /home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-base.cmxa /home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-unthreaded.cmxa /home/lhooq/.opam/4.04.0/lib/tsdl/tsdl.cmxa min.ml 
+ as -o 'min.o' '/tmp/camlasm201bd8.s' 
+ as -o '/tmp/camlstartup7113e2.o' '/tmp/camlstartup4724f2.s' 
+ gcc -o 'min.native' '-L/home/lhooq/.opam/4.04.0/lib/result' '-L/home/lhooq/.opam/4.04.0/lib/bytes' '-L/home/lhooq/.opam/4.04.0/lib/ctypes' '-L/home/lhooq/.opam/4.04.0/lib/tsdl' '-L/home/lhooq/.opam/4.04.0/lib/ocaml' '/tmp/camlstartup7113e2.o' '/home/lhooq/.opam/4.04.0/lib/ocaml/std_exit.o' 'min.o' '/home/lhooq/.opam/4.04.0/lib/tsdl/tsdl.a' '/home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-unthreaded.a' '/home/lhooq/.opam/4.04.0/lib/ctypes/ctypes-foreign-base.a' '/home/lhooq/.opam/4.04.0/lib/ctypes/ctypes.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/str.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/bigarray.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/unix.a' '/home/lhooq/.opam/4.04.0/lib/result/result.a' '/home/lhooq/.opam/4.04.0/lib/ocaml/stdlib.a' '-L/usr/local/lib' '-Wl,-rpath,/usr/local/lib' '-Wl,--enable-new-dtags' '-lSDL2' '-ltsdl' '-Wl,--no-as-needed' '-lffi' '-lctypes-foreign-base_stubs' '-Wl,--no-as-needed' '-lffi' '-lctypes_stubs' '-Wl,--no-as-needed' '-lcamlstr' '-lbigarray' '-lunix' '/home/lhooq/.opam/4.04.0/lib/ocaml/libasmrun.a' -lm -ldl 
+0

Le nom du paquet 'apt' est' libsdl2-dev'. – RichouHunter

+0

Oui, que je sais, mais la version est '2.0.4'. – Lhooq

+0

Il semble que la bibliothèque sdl ne puisse pas être trouvée. Pourriez-vous signaler la sortie de: 'ocamlobjinfo $ (opam config var tsdl: lib) /tsdl.cmxa | grep Extra' et 'sdl2-config --libs' –

Répondre

1

Cela semble être un problème mineur dans tsdl, voir ceci pour plus d'informations: https://github.com/dbuenzli/tsdl/issues/38

Il est fixé dans le maître. Comme l'auteur vous suggère que vous pouvez (pour l'instant) faire cela comme une solution temporaire:

opam pin add tsdl --dev

EDIT: comme indiqué par @dbuenzli en dessous de c'est fixé à 0.9.4 qui est sur le chemin de l'OPAM.

+0

Merci pour l'aide @esl. Pourriez-vous s'il vous plaît ajouter que cela est corrigé dans 0.9.4 qui est sur le chemin de l'opam repo https://github.com/ocaml/opam-repository/pull/9770 (il peut prendre un peu de temps pour fusionner comme je suis en train de nettoyer un peu de choses autour du dossier tsdl en même temps) –