[R-SIG-Mac] configure: error: "liblzma library and headers are required"

Marius Hofert m@r|u@@ho|ert @end|ng |rom uw@ter|oo@c@
Sun Jun 12 02:25:56 CEST 2022


Hi Simon,

thanks a lot for your help. I have to admit, a lot of what you wrote is entirely
new to me (probably because we are on arm64 now). So far, on Intel Macs, I
always could easily install R from source (see below) and thus had several
versions available, my own starter script, version-independent library of R
packages, etc.  I used to use /usr/local/R for all of that (see below), which,
now will be /opt/R/arm64 I assume. However, I don't understand why suddenly
lzma.h is not found (even though it's inside /opt/R/arm64 as recommended and
also xz is found, etc.).

1) You mentioned "The flags used by CRAN... which works for the binaries
installed using source(...)".  This part I don't understand. If you already have
R running (to be able to execute the source(); install.libs() command), why are
the flags for compiling R relevant?

2) Concerning the flags on
https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R4/conf.big-sur-arm64, are
these the flags used per default if I do ./configure on arm64 or does it mean
that I need to provide all those flags on arm64 because they are not the
default?

3) The install.R script you mentioned already needs to be execute from R, so you
assume R is already installed.  Is the recommended way then to install R via
binaries and then to use install.R to install the tools required to build
packages from source? Can you then still have various R versions installed
(and if so, where are they located)?

As a clarification, what I always did on Intel Macs and what I also tried now is this:

1) Install all preliminaries (GCC, Fortran, XQuartz, qpdf, Tcl/Tk, Open MPI,
GSL, GMP, MPFR, Java, XML, PCRE2, xz) either via brew or directly from source
(./configure, make, make install)

2) create /usr/local/R for the various R versions and ./usr/local/R/library for
a version-independent library of packages

3) Download R versions, say R-4.2.0.tar.gz and unpack them to /usr/local/R/R-4.2.0_source

4) Create /usr/local/R/R-4.2.0_build and execute:
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
../R-4.2.0_source/configure --enable-R-shlib --with-tcl-config=/Library/Frameworks/Tcl.framework/Versions/8.6/tclConfig.sh --with-tk-config=/Library/Frameworks/Tk.framework/tkConfig.sh

The latter configure step produced the lzma.h error described. Given what you wrote
I assume I failed to specify the location of the dependencies in ./configure. So
would the right ./configure then specify all flags provided by https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R4/conf.big-sur-arm64 ?


Thanks again for your help & cheers,
Marius

________________________________________
From: Simon Urbanek <simon.urbanek using R-project.org>
Sent: Saturday, June 11, 2022 19:29
To: Marius Hofert
Cc: r-sig-mac using r-project.org
Subject: Re: [R-SIG-Mac] configure: error: "liblzma library and headers are required"

Marius,

most package systems (ours as well as Homebrew) don't use /usr/local on arm64 to not cause inadvertent conflicts with x86_64 binaries, so they must be explicitly added to flags. You failed to provide any details, but I suspect you didn't configure R to use whichever location is necessary for the dependencies since only /usr/local is searched by default. The flags used by CRAN can be seen at
https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R4/conf.big-sur-arm64
which works for the binaries installed using

source("https://mac.R-project.org/bin/install.R")
install.libs("r-base-dev")

(Tcl/TK is not included, if needed you can install it from the release package).

Note that PATH has nothing to do with locating libraries by dyld - PATH is only used for executables so your $LOCAL/bin has to be on the PATH for pkg-config. Also note that mixing different systems is prone to cause chaos, because static and dynamic libraries have different precedence. So make sure you pick one choice (CRAN or Homebrew or Macport etc.) and stick with it.

Cheers,
Simon



> On Jun 12, 2022, at 1:52 AM, Marius Hofert <marius.hofert using uwaterloo.ca> wrote:
>
> Hi,
>
> I'd like to install R from source on a MacBook Pro 14 (M1 Pro Max) and do that
> for the first time under Apple Silicon.  I could install all preliminaries from
> source as I normally did under Intel Macs (even tcl and tk, gsl, gmp, mpfr, etc.).
> However, the configure step of R fails with:
>
> ...
> checking for lzma_version_number in -llzma... yes
> checking for lzma.h... no
> configure: error: "liblzma library and headers are required"
>
> Related to this problem, I found the references below. However, none of the
> suggested solutions worked for me.
>
> The problem seems to be the installation of xz (and, as the references suggest, a similar
> problem will arise from pcre2). The header file lzma.h is not found.
>
> Here are the things I tried:
>
> 1) A plain 'brew install xz'.
>
> 2) Adding the directories where lzma.h is found to PATH:
> /usr/local/bin/xz/include/lzma.h
> /opt/R/arm64/include/lzma.h
> /opt/homebrew/include/lzma.h
> /opt/homebrew/Cellar/xz/5.2.5/include/lzma.h
>
> 3) Following https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Native-builds:
> 3.1) Creating /opt/R/arm64
> 3.2) Downloading xz-5.2.5-darwin.20-arm64.tar.xz from https://mac.r-project.org/bin/darwin20/arm64/
> and unpacking it to /opt/R/arm64
> 3.3) Adding /opt/R/arm64 to PATH
>
> How can xz be installed in Apple Silicon so that configure finds it including headers?
>
> Let me know if you need more information.
>
> Thanks & cheers,
> Marius
>
> References:
> https://groups.google.com/g/r-sig-mac/c/UPPDNxn7ab4
> https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Prerequisites
> https://mac.r-project.org/bin/darwin20/arm64/
> https://www.mail-archive.com/r-sig-mac@r-project.org/msg05844.html
> https://stackoverflow.com/questions/40222371/install-r-with-shared-library-in-osx-liblzma-library-missing
> https://pj.freefaculty.org/blog/?p=315
>
>
>
>
>
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>



More information about the R-SIG-Mac mailing list