r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
175 stars 28 forks source link

installation problems on macOS #322

Closed alexWhitworth closed 1 year ago

alexWhitworth commented 2 years ago

I'm trying to install units on Mac OSX 12.5. I have tried both installing udunits from brew and by downloading the tarball from the FTP noted in this package's README.

Any help much appreciated!

$ which openssl && which udunits2
/opt/local/bin/openssl
/opt/local/bin/udunits2

Error:

All of the following fail with the same error:

R> install.package("units")

* installing *source* package ‘units’ ...
** package ‘units’ successfully unpacked and MD5 sums checked
** using staged installation
configure: units: 0.8-0
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++-12 -fopenmp accepts -g... yes
checking how to run the C++ preprocessor... g++-12 -fopenmp -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for error_at_line... no
checking for gcc... gcc-12 -fopenmp
checking whether we are using the GNU C compiler... yes
checking whether gcc-12 -fopenmp accepts -g... yes
checking for gcc-12 -fopenmp option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/private/var/folders/ck/tf4vrh210zs3m3kqhy5wlqgw0000gn/T/Rtmp1zfKhA/R.INSTALL3b0e6c569aa9/units':
configure: error:
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------

See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/opt/homebrew/lib/R/4.2/site-library/units’

SessionInfo

R> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin21.5.0 (64-bit)
Running under: macOS Monterey 12.5

Matrix products: default
BLAS:   /opt/homebrew/Cellar/openblas/0.3.21/lib/libopenblasp-r0.3.21.dylib
LAPACK: /opt/homebrew/Cellar/r/4.2.1_2/lib/R/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1

Makevars:

CBASE=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

LOC_HOMEBREW=/opt/homebrew
GCC=$(LOC_HOMEBREW)/opt/gcc
GCCVER=12

GETTEXT=$(LOC_HOMEBREW)/opt/gettext
LOC_CLANG=/usr/bin/clang
LOC_CLANGpp=/usr/bin/clang++
LOC_FORTRAN=$(LOC_HOMEBREW)/bin/gfortran
LOC_LLVM=$(LOC_HOMEBREW)/opt/llvm

CC=gcc-$(GCCVER) -fopenmp
CXX=g++-$(GCCVER) -fopenmp

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe

LDFLAGS=-L/opt/homebrew/Cellar/gettext/0.21/lib -L$(LOC_LLVM)/lib -Wl,-rpath,$(LOC_LLVM)/lib
CPPFLAGS=-I/opt/homebrew/Cellar/gettext/0.21/include -I$(LOC_LLVM)/include -I$(XCBASE)

I have also tried adding various combinations of the below, though none of them have any impact on the installation error I receive.

# openssl + udunits
LDFLAGS=-L/opt/local/bin/openssl@1.1/lib
CPPFLAGS=-I/opt/local/bin/openssl@1.1/include
LDFLAGS=-L/opt/local/bin/udunits2/lib
CPPFLAGS=-I/opt/local/bin/udunits2/include

CFLAGS += -I/opt/local/bin/udunits2/lib
CPPFLAGS += -I/opt/local/bin/udunits2/include
Enchufa2 commented 2 years ago

Usually only the binary program is under */bin/. I very much doubt that the lib and the headers are there too. Did you specifically try what the error message suggests?

Enchufa2 commented 2 years ago

See also https://github.com/r-quantities/units/issues/236

alexWhitworth commented 2 years ago

Yes, I also specifically tried what the error suggests (updated OP appropriately). Based on #236, I tried adding the following to Makevars and rerunning above commands. All lead to the same failure

CPPFLAGS=-I/usr/local/include

Enchufa2 commented 2 years ago

Then I suggest you try asking for help in the r-sig-mac mailing list. Package installation works with CRAN R for macOS, but unfortunately we ourselves are not macOS users, so we cannot debug issues with setups beyond what CRAN offers.

edzer commented 2 years ago

What is wrong with installing a binary package?

dewoller commented 1 year ago

install.packages("units", configure.args = c("--with-udunits2-include=/opt/homebrew/Cellar/udunits/2.2.28/include", "--with-udunits2-lib=/opt/homebrew/Cellar/udunits/2.2.28/lib"))

Worked for me. I think brew is installing it in a new place. On Mac Silicon (arm64), fwiw

alexWhitworth commented 1 year ago

Interesting. @dewoller's command with modifications for my udunits location and a blank ~/R/.Makevars worked for me. So, it appears the Makevars file may have been the issue (or the upgrade to R 4.3.1).