Closed stevenvar closed 4 years ago
Same thing will occur under macOS Catalina 10.15.1 with XQuartz installed.
Sorry, I do not quite understand OCaml's build system, but I can provide any further information to help.
Did you try doing
export LIBRARY_PATH=/opt/X11/lib
?
It works!
Thanks!
For info, LIBRARY_PATH
is a PATH
-like variable that is used to extend the list of directories where the compiler (gcc
or similar) looks for static and shared variables at link-time. It is equivalent to adding those directories using an -L
flag. As the location of libX11
is nonstandard on OS X the location of the library needs to be passed somehow to the compiler, which one can do using this environment variable, without need to modify the graphics
build instructions.
That said, @nojb - presumably OCaml's configure
script figured this out before (on the "just work" principle) - is it just that we're missing some logic in the conversion to Dune?
Just confirming that the
export LIBRARY_PATH=/opt/X11/lib
line works. Thanks!
David Allsopp (2019/12/05 01:35 -0800):
That said, @nojb - presumably OCaml's
configure
script figured this out before (on the "just work" principle) - is it just that we're missing some logic in the conversion to Dune?
It might be the case that I didn't implement looking in several directories for the graphics library, sorry about that.
@shindere - it's OK, the report suggests that this did work when the graphics library was in OCaml! I think AC_PATH_X
was doing everything needed - the problem now for 4.09+ is that the Dune configuration system is not doing enough, and I wonder if we should fix that.
(I think we should fix it, because the graphics library's principal use remains in teaching, where it's very annoying to have extra steps for getting it working...)
David Allsopp (2019/12/05 02:07 -0800):
(I think we should fix it, because the graphics library's principal use remains in teaching, where it's very annoying to have extra steps for getting it working...)
I agree. It's just that we need to figure out who "we" is :)
I think the problem can be traced back to the https://github.com/ocaml/opam-repository/blob/master/packages/conf-libX11/conf-libX11.1/opam, where
[ "sh" "-exc" """PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig" pkg-config --libs x11""" ] {os = "macos"}
After setting the PKG_CONFIG_PATH, the pkg-config still cannot identify --libs x11.
I don't know how to modified it and recompile graphics locally :(
@ZhengchaoJiang could you look if you have a file x11.pc on your system?
If it's just a missing pkg-config path, I guess we can add it to conf-libX11 and also add a dune-configurator program in graphics to get the flags from pkg-config
Please, when you include textual content, as much as possible it would be better to include the textual content itself rather than a screen shot. This is useful for blind persons like me and also for search engines (there is a joke that says that the most well known blind user of the web is Google).
Ok, I am a noob here anyway:)
i tried to add the line below to my .zshrc
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig"
then from my terminal
pkg-config --list-all | grep x11
x11-xcb X11 XCB - X Library XCB interface
x11 X11 - X Library
the X11 can be detected.
I setup the build to use dune-configurator, @ZhengchaoJiang could you give #17 a try?
dune build ocamlmklib src/dllgraphics_stubs.so,src/libgraphics_stubs.a (exit 2) (cd _build/default && /Users/sv281/.opam/4.08.1/bin/ocamlmklib.opt -g -o src/graphics_stubs src/color.o src/draw.o src/dump_img.o src/events.o src/fill.o src/image.o src/make_img.o src/open.o src/point_col.o src/sound.o src/subwindow.o src/text.o -lX11) ld: library not found for -lX11 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [default] Error 1
I changed to your branch locally, it still not working
dune build [6:54:04]
ocamlmklib src/dllgraphics_stubs.so,src/libgraphics_stubs.a (exit 2)
(cd _build/default && /Users/Bash/.opam/4.09.0/bin/ocamlmklib.opt -g -o src/graphics_stubs src/color.o src/draw.o src/dump_img.o src/events.o src/fill.o src/image.o src/make_img.o src/open.o src/point_col.o src/sound.o src/subwindow.o src/text.o -lX11)
ld: library not found for -lX11
clang: error: linker command failed with exit code 1 (use -v to see invocation)
could you provide the result of the following commands?
$ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig"
$ pkg-config --cflags x11
$ pkg-config --libs x11
and also: uname -s
(just to be sure)
Here you go :
$ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig"
$ pkg-config --cflags x11
-I/opt/X11/include
$ pkg-config --libs x11
-L/opt/X11/lib -lX11
$ uname -s
Darwin
@stevenvar thanks. From the build error you reported in your previous message, it seems that the flags are not being obtained from pkg-config in src/discover/discover.ml
. Could you add a couple of printfs in the from_pkg_config
function in this file to see what's going on?
Ok what's happening is that the second match returns a None:
let from_pkg_config c =
Printf.printf "entering";
let fallback = ([], [ "-lX11" ]) in
match C.Pkg_config.get c with
| None -> fallback
| Some pc -> (
match C.Pkg_config.query pc ~package:"x11" with
| None -> Printf.printf "fallback"; fallback
| Some { cflags; libs } -> (cflags, libs) )
prints "fallback"
The other seemingly wrong thing is that the "match os c" in the entry point of the file returns Other
Ok, so os c
returning Other
is probably the issue. Could you provide the output of:
$ dune exec -- src/discover/discover.exe -verbose
?
Sure thing. Here you go:
run: /Users/sv281/.opam/default/bin/ocamlc.opt -config
-> process exited with code 0
-> stdout:
| version: 4.09.0
| standard_library_default: /Users/sv281/.opam/default/lib/ocaml
| standard_library: /Users/sv281/.opam/default/lib/ocaml
| ccomp_type: cc
| c_compiler: cc
| ocamlc_cflags: -O2 -fno-strict-aliasing -fwrapv
| ocamlc_cppflags: -D_FILE_OFFSET_BITS=64 -D_REENTRANT
| ocamlopt_cflags: -O2 -fno-strict-aliasing -fwrapv
| ocamlopt_cppflags: -D_FILE_OFFSET_BITS=64 -D_REENTRANT
| bytecomp_c_compiler: cc -O2 -fno-strict-aliasing -fwrapv -D_FILE_OFFSET_BITS=64 -D_REENTRANT
| native_c_compiler: cc -O2 -fno-strict-aliasing -fwrapv -D_FILE_OFFSET_BITS=64 -D_REENTRANT
| bytecomp_c_libraries: -lm -lpthread
| native_c_libraries: -lm
| native_pack_linker: ld -r -o
| ranlib: ranlib
| architecture: amd64
| model: default
| int_size: 63
| word_size: 64
| system: macosx
| asm: clang -arch x86_64 -Wno-trigraphs -c
| asm_cfi_supported: true
| with_frame_pointers: false
| ext_exe:
| ext_obj: .o
| ext_asm: .s
| ext_lib: .a
| ext_dll: .so
| os_type: Unix
| default_executable_name: a.out
| systhread_supported: true
| host: x86_64-apple-darwin18.7.0
| target: x86_64-apple-darwin18.7.0
| flambda: false
| spacetime: false
| safe_string: false
| default_safe_string: true
| flat_float_array: true
| afl_instrument: false
| windows_unicode: false
| supports_shared_libraries: true
| exec_magic_number: Caml1999X026
| cmi_magic_number: Caml1999I026
| cmo_magic_number: Caml1999O026
| cma_magic_number: Caml1999A026
| cmx_magic_number: Caml1999Y026
| cmxa_magic_number: Caml1999Z026
| ast_impl_magic_number: Caml1999M026
| ast_intf_magic_number: Caml1999N026
| cmxs_magic_number: Caml1999D026
| cmt_magic_number: Caml1999T026
-> stderr:
run: uname -s
-> process exited with code 0
-> stdout:
| Darwin
-> stderr:
which: pkg-config
-> found: /usr/local/bin/pkg-config
which: brew
-> found: /usr/local/bin/brew
run: /usr/local/bin/brew --prefix
-> process exited with code 0
-> stdout:
| /usr/local
-> stderr:
run: /usr/local/bin/pkg-config --print-errors x11
-> process exited with code 1
-> stdout:
-> stderr:
| Package x11 was not found in the pkg-config search path.
| Perhaps you should add the directory containing `x11.pc'
| to the PKG_CONFIG_PATH environment variable
| No package 'x11' found
EDIT: accidentally ran it with ocaml 4.08.1. I corrected it but the same happens with 4.09
Ok I think I found the problem.
For some reason running uname -s in the "os" function returns the stdout "Darwin\n" and not "Darwin"
When changing the line
| { exit_code = 0; stdout = "Darwin"; _ } -> Darwin
to
| { exit_code = 0; stdout = "Darwin\n"; _ } -> Darwin
Everything seems to work.
ah, yes of course I forgot to trim the output :man_facepalming:
I changed the code in #17 to trim the output. If you could do a final test to confirm it works as expected, I'll merge and prepare a new release. Thanks
Yes that works! thanks
Cool, merging :)
and releasing: https://github.com/ocaml/opam-repository/pull/15455
Completely unrelated: in my mail, your emoticon get displayed as🤦 ♂ I.e. "man hitting forehead" = "woman hitting forehead + male" Mysteries of unicode.
By the way, I had the same problem, and this release fixes it for me too. (I'm using MacOS 10.15.1, but with macports rather than brew)
Haha, and I actually typed :man_facepalming:
!
Glad it fixes the issue for you too Jacques!
@garrigue - that's correct. "man facepalming" is a sequence of characters, it means your MUA isn't processing the zero-width-joiners correctly (see here). The "person facepalming" emoji is permitted to have the appearance of any gender (as you can see on that page). Skin-tone and various other glyphs are selected this way via sequences.
Hi,
I'm unable to install the package on MacOS 10.14 (Mojave), while it did work when graphics was bundled with ocaml.
Here is the error:
I have xquartz installed.
Doing a
(as mentioned here) just changes the error to:
Any idea?
Thanks