Binding 异常Dl.Dl_错误:未定义符号:SDL_GetError
所以,我想使用Binding 异常Dl.Dl_错误:未定义符号:SDL_GetError,binding,ocaml,sdl-2,Binding,Ocaml,Sdl 2,所以,我想使用Tsdl,下面是我所做的: 我找不到带有apt get的SDL2.0.5,所以我下载了它,/configure&&make&&sudo make install opam安装tsdl 然后我创建了一个文件main.ml(在上给出了一个示例): ocamlfind ocamlopt-package tsdl-linkpkg-o main.native main.ml 它起作用了,现在我的问题来了: ./main.native Fatal error: exception Dl.
Tsdl
,下面是我所做的:
- 我找不到带有apt get的
,所以我下载了它,SDL2.0.5
/configure&&make&&sudo make install
opam安装tsdl
- 然后我创建了一个文件
(在上给出了一个示例):main.ml
ocamlfind ocamlopt-package tsdl-linkpkg-o main.native main.ml
./main.native
Fatal error: exception Dl.DL_error("./main.native: undefined symbol: SDL_GetError")
我是否做错了什么,或者我是否需要明确地告诉我的SDL2库在哪里,或者其他什么
更新:
> 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
更新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)
更新3
lhooq@lhooq ~/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
lhooq@lhooq ~/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
这似乎是tsdl中的一个小问题,有关更多信息,请参阅: 它在master中是固定的。正如作者所建议的,您可以(目前)将此作为临时修复:
opam引脚添加tsdl--dev
编辑:如下面的@dbuenzli所示,这是在0.9.4中修复的,它正在前往opam。包名是
libsdl2 dev
。是的,我知道,但版本是2.0.4
。看起来无法找到sdl库。请您报告一下:ocamlobjinfo$(opam-config-var-tsdl:lib)/tsdl.cmxa | grep-Extra
和sdl2-config-libs
的输出,Debian存储库再次罢工。makeinstall
为您提供了什么?一堆.so
文件?您确定/usr/local/lib
在rpath
中吗?您还可以检查一下/usr/local/lib/libSDL2.so
是否存在。通过调用LD_LIBRARY\u PATH=/usr/local/lib./main.native
,它是否可以工作?谢谢@esl的帮助。请您补充一下,这在0.9.4中已得到修复,该版本正在向opam回购(合并可能需要一些时间,因为我同时正在清理tsdl包depText周围的一些内容)
lhooq@lhooq ~/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
lhooq@lhooq ~/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