ocaml graphics not working on popular Linux distros; ocaml should use pkg-config to get X11 switches #5477
Original bug ID: 5477
There is now pkg-config support for libx in x.org's version of X for some time. This is a more reliable way for finding libx than searching in hard-coded locations, as it is currently done in Ocaml's configure script.
The problem becomes now more urgent because distributions have started to ship multiarch binaries/libraries which are no longer stored at the classic places. The libraries are now in /usr/lib/ or /usr/lib//, and ocaml fails to find them. Affected distros are Ubuntu Natty and Debian Wheezy so far.
Steps to reproduce
The suggested fix is to try "pkg-config --libs x11" before starting to search possible places for libx.
pkg-config is supported for X11 since around 2005, and is now even widely available.
The text was updated successfully, but these errors were encountered:
Comment author: gerd
Looking at Philippe's patch. On my system the two pkg-config commands output the empty string. I think this is not properly handled: "test -f $dir/X11/X.h" does not work when $dir is empty. Same with the library test. I think the proper way to go is to just believe pkg-config when it exits with code 0, and not testing the existence of files. A meaningful test would be compiling a test program with the flags.
Also, we should be prepared that pkg-config is not available, and just use the old code then.
Philippe: I don't understand the sed.
Comment author: @lefessan
The patch requires some work, to be applied to trunk (it is based on 3.12.1).
In the meantime, maybe some developers could try it on their systems, to be sure it does not break working configuration.
I tested it on Linux amd64/Ubuntu 10.10 Maverick, and it worked for me.
Comment author: @damiendoligez
I have adapted Gerd's patch to trunk and removed the bug. Tested on MacOSX 10.6. It selects macports' X11 library in preference to Apple's but that works just as well.
Tested also on 32-bit Ubuntu 11.04.
Committed to trunk [3.13.0] (commit 12110)