s-u / Cairo

R graphics device using cairo graphics library for creating high-quality output
12 stars 10 forks source link

X11 back-end breaks without libXt #39

Closed glin closed 2 years ago

glin commented 2 years ago

Hi, when installing Cairo from source on Linux, libXt seems to be required in addition to Cairo, but libXt isn't mentioned in the SystemRequirements field or package README.

Without the development files for libXt installed, Linux users run into compilation errors without an obvious resolution like this:

> install.packages("Cairo")
...
gcc -I"/opt/R/4.2.1/lib/R/include" -DNDEBUG -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16   -I. -Iinclude  -I/usr/local/include  -g -O2 -fpic  -g -O2  -c xlib-backend.c -o xlib-backend.o
xlib-backend.c:34:10: fatal error: X11/Intrinsic.h: No such file or directory
   34 | #include <X11/Intrinsic.h>      /*->    Xlib.h  Xutil.h Xresource.h .. */
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [/opt/R/4.2.1/lib/R/etc/Makeconf:168: xlib-backend.o] Error 1
ERROR: compilation failed for package ‘Cairo’
* removing ‘/opt/R/4.2.1/lib/R/library/Cairo’

Searching for the error message turns up many questions over the years about Cairo also requiring libXt development files (e.g. libxt-dev on Ubuntu/Debian or libXt-devel on CentOS/RHEL/Fedora):

To help users install Cairo on Linux, would you be open to adding libXt to SystemRequirements or the package README?

This would also help out tools that use SystemRequirements, like the automatic system dependency installation used by the GitHub Actions for R, R-hub, and the Linux binary packages from RStudio Package Manager (https://packagemanager.rstudio.com/). This was the original motivation for opening this, via https://github.com/rstudio/r-system-requirements/issues/31.

s-u commented 2 years ago

Interesting, sounds reasonable - I would expect that libcairo would already cover it, but it's quite possible that we use additional X11 handling for things like the locator, so that has added the Xt dependency.

Technically, it is not required, it just won't build the X11 back-end which is optional. I wonder what is the best way forward. The most logical way to address this would be to check for libXt in configure and disable X11 support if it is not present. That would fix the reported bug. However, it would mean that users that don't install libXt won't have X11 support - which is fine, but perhaps they wanted X11 support - it's not clear to me.

So in short, IibXt is not a requirement, so modifying SystemRequirements: doesn't seem right like the right way - cairo is the only actual requirement. However, I'm not sure how automatic systems that you list are dealing with optional dependencies. There is no offical SystemSuggests: entry or some such.

s-u commented 2 years ago

It turns out it's much easier than that - we don't need Xt =)

glin commented 2 years ago

That's fantastic, and I can confirm that the latest development version no longer requires libXt. Thanks!