udunits2 R install: udunits2.h not found - r

I'm trying to install udunits2 in R in order to satisfy the dependency for the ggforce package. However, the installer keeps failing on the check for udunits2. I have tried the instructions in this (udunits 2 devel is installed as shown here.)
and this thread, which produces the same result as trying to install.packages('udunits2').
I was able to get it working on my Mint machine by just installing udunits2-dev, however I'm quite new to Fedora, and am not sure what is causing this.
System info:
Fedora 28, R-3.4.4
EDIT
Error output when trying to install using install.packages("udunits2", configure.args = "--with-udunits2-lib=/usr/bin/udunits2"):
* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64
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 gcc -m64 accepts -g... yes
checking for gcc -m64 option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking how to run the C preprocessor... gcc -m64 -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... 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 udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking for ut_read_xml in -ludunits2... yes
-----Error: udunits2.h not found-----
If the udunits2 library is installed in a non-standard location,
use --configure-args='--with-udunits2-lib=/usr/local/lib' for example,
or --configure-args='--with-udunits2-include=/usr/include/udunits2'
replacing paths with appropriate values for your installation.
You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
environment variables.
If udunits2 is not installed, please install it.
It is required for this package.

On Fedora the header file is installed in /usr/include/udunits2, c.f. this Github issue. Solution provided there:
sudo yum install udunits2-devel
Followed by:
install.packages("udunits2",configure.args='--with-udunits2-include=/usr/include/udunits2/')

Get the source code for udunits2 from the website: ftp://ftp.unidata.ucar.edu/pub/udunits
Download, compile, and install udunits2:
# Download the library
wget ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.26.tar.gz
# Decompress the archive
tar xf udunits-2.2.26.tar.gz
# Navigate to the archive
cd ./udunits-2.2.26
# Configure the build for your system
./configure prefix=$HOME/.local
# Use 4 jobs to build quickly
make -j 4
# Install to our prefix
make install
Start a new R session and install the udunits2 R package:
(Make sure to change $HOME to your actual home path)
install.packages(
"udunits2",
configure.args = '--with-udunits2-include=$HOME/.local/include/'
)
Tested on this system:
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.5 (Santiago)

As a supercomputer server user without permission of sudo yum, I found installing udunits2-devel quite diffcult. Alternatively, i found spack https://spack.readthedocs.io/en/latest/basic_usage.html
quite useful for installing udunits2&units R packages:
spack install r-udunits2
spack install r-units
Spack will automatically install dependent packages, and i don't have to install udunits2-devel by myself.
Since i installed units R package for ggforce R package, and ggforce can't be installed by spack, i need to load units before entering R and then install ggforce:
$source <(spack module tcl loads r-units)
$source <(spack module tcl loads r-udunits2)
$R
>install.packages("ggforce")
and everything worked well.

Related

configuration failed for package ‘rJava’ when running rize - R

I am trying to use the rize package to create a Dockerfile for ShinyApp. Starting the rize::shiny_dockerize() comand from the App dir. One of the packages which are required is the xlsx (Probably hier it is trying also to install rJava). I get the following error:
trying URL 'https://cran.rstudio.com/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)
==================================================
downloaded 9.0 MB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
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 gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... 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 string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver : '/usr/bin/jar'
compiler : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags : '-I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux'
java libs : '-L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... ./configure: line 3766: /usr/bin/java: No such file or directory
no
configure: error: Java interpreter '/usr/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/local/lib/R/site-library/rJava’
Error in i.p(...) :
(converted from warning) installation of package ‘rJava’ had non-zero exit status
Calls: <Anonymous> ... with_rprofile_user -> with_envvar -> force -> force -> i.p
Execution halted
The command '/bin/sh -c R -e "setwd('/srv/shiny-server/app'); automagic::automagic()"' returned a non-zero code: 1
Error in rize::shiny_dockerize() : object 'view_app' not found
does anyone how I can bring this to work in the rize package?
It looks like you have issues with setting proper location of Java. Note that making R happy with Java might be a little bit of struggle.
Take a look here: http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/ for a sample. It is macOS based, but still, it should work fine.
Basically, what you want to do is to set your JAVA_HOME such way it points at Java installation. Once it's done, you can run R cmd javareconf like this
> sudo R CMD javareconf \
JAVA_HOME=${JAVA_HOME} \
JAVA=${JAVA_HOME}/bin/java \
JAVAC=${JAVA_HOME}/bin/javac \
JAVAH=${JAVA_HOME}/bin/javah \
JAR=${JAVA_HOME}/bin/jar
Make sure you have gcc installed and that you can compile simple C code.
rJava takes some time to install and is uaully a package which gives me a lot of issues. Here is what has generally worked for me in the past.
Install the JAVA JDK from: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
In the command line run : sudo R CMD javareconf
if rJava library is not installed, (this particular version works for me but you could try installing the latest version)
devtools::install_version("rJava", version = "0.9-9", repos = "http://cran.us.r-project.org")
Restart R and attempt to reload the xlsx package
Caution: A lot of stackoverflow questions on this topic have advised people to alter environment variables. This has not been nessasary for me personally.
sudo R CMD javareconf should take care of this.

How to install & locate ODBC headers sql.h and sqlext.h on a macOS

I am trying to install package RODBC via CRAN on MacBook Air with OS 10.12.
I am receiving the below error:
Installing package into ‘/Users/aaron.samuels/Library/R/3.3/library’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need compilation of
C/C++/Fortran: ‘RODBC’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘RODBC’
trying URL 'https://cran.rstudio.com/src/contrib/RODBC_1.3-14.tar.gz'
Content type 'application/x-gzip' length 1163799 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
* installing *source* package ‘RODBC’ ...
** package ‘RODBC’ successfully unpacked and MD5 sums checked
checking for gcc... clang
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 clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -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 sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking sqlext.h usability... no
checking sqlext.h presence... no
checking for sqlext.h... no
configure: error: "ODBC headers sql.h and sqlext.h not found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/Users/aaron.samuels/Library/R/3.3/library/RODBC’
Warning in install.packages :
installation of package ‘RODBC’ had non-zero exit status
The downloaded source packages are in
/private/var/folders/3l/nrtzvm592736jz_qh_5l1wbmffq3bz/T/RtmpeuPUR0/downloaded_packages
Any suggestion on how I can easily install these headers and subsequently successfully install RODBC?
I found an official Microsoft Source that enable the ODBC driver.
You just need to run this lines on the Terminal
/usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install --no-sandbox msodbcsql17 mssql-tools
Use the below command to get rid of error thrown while installing RODBC package in R.
sudo zypper install unixODBC-devel
Thanks #Rafa Barragan.
Following commands worked for me on my mac-os (Mojave version).
Run following commands in terminal -
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql17 mssql-tools
configure: error: "ODBC headers sql.h and sqlext.h not found" means that ODBC drivers are not installed on your mac.
I would install iODBC and make sure the header files are present in the path

Can't get RQuantLib working with brew installed quantlib under osx 10.9.4

I've been trying to install RQuantLib package via
install.packages("RQuantLib")
It keeps giving me the following errors
* installing *source* package ‘RQuantLib’ ...
** package ‘RQuantLib’ successfully unpacked and MD5 sums checked
checking for g++... g++
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++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for R... yes
checking for quantlib-config... yes
checking for Boost development files... no
configure: error: Boost development files not found
ERROR: configuration failed for package ‘RQuantLib’
* removing ‘/usr/local/Cellar/r/3.1.1/R.framework/Versions/3.1/Resources/library/RQuantLib’
I've already done
brew install boost
brew install quantlib
and I've checked the sym links for both, which should be fine (done unlink/link for both).
SOLUTION :
Used the command below based on edd's answer, worked for me
install.packages("RQuantLib", configure.args="--with-boost-include=/usr/local/include/ --with-boost-lib=/usr/local/lib/")
Try to do it either in a shell based on the *.tar.gz file using these
edd#max:~/git/rquantlib(master)$ ./configure --help|grep boost
--with-boost-include=INCLUDE_PATH
--with-boost-lib=LIB_PATH
edd#max:~/git/rquantlib(master)$
or look at the help for install.packages() where you can pass arguments to configure as well -- I find the first method easier.
In essence, it seems that we need to help configure find your Boost headers (and then probably also the library).

Install RMySQL to use with InfiniDB (without installing mysql completely)

I've successfully installed InifiniDB on CENTOS 6.5.
InfiniDB is a columnar DB "compatible" with MySQL (same port etc.: I've even managed to install the latest version of MySQLWorkbench and works has a charm with InifiniDB - believing to deal with just another install of MySQL).
The installation does not have MySQL as I don't need it :)
I tried to install RMySQL from RStudio Server, but I am unable to install: the installation expect to find a copy of MySQL somewhere and I do not have it.
See below the installation log. I put :/usr/local/Calpont/mysql/bin in my PATH, but this didn't have any effect.
Please consider that the inspiration for this comes from InfiniDB itself: see here http://infinidb.co/system/files/Calpont%20InfiniDB_Quick%20Start_for%20R.pdf
I guess the main problem, comparing the error and the InfiniDB paper, is that they suggest to create the following global variables:
(From InfiniDB paper) RMySQL must be configured with the correct MySQL directory
(which comes with InfiniDB) and the developer library directory.
o Example in Ubuntu or CentOS:
export MYSQL_INC=”/usr/include/mysql/”
export MYSQL_LIB=”/usr/local/Calpont/mysql/lib/mysql”
But my installation on CENTOS does not have a mysql folder at /usr/include/mysql/.
Any suggestions?
==============
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
opened URL
==================================================
downloaded 161 Kb
* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for compress in -lz... yes
checking for getopt_long in -lc... yes
checking for mysql_init in -lmysqlclient... no
checking for egrep... grep -E
checking for ANSI C header files... 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 mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking /usr/local/include/mysql/mysql.h usability... no
checking /usr/local/include/mysql/mysql.h presence... no
checking for /usr/local/include/mysql/mysql.h... no
checking /usr/include/mysql/mysql.h usability... no
checking /usr/include/mysql/mysql.h presence... no
checking for /usr/include/mysql/mysql.h... no
checking /usr/local/mysql/include/mysql/mysql.h usability... no
checking /usr/local/mysql/include/mysql/mysql.h presence... no
checking for /usr/local/mysql/include/mysql/mysql.h... no
checking /opt/include/mysql/mysql.h usability... no
checking /opt/include/mysql/mysql.h presence... no
checking for /opt/include/mysql/mysql.h... no
checking /include/mysql/mysql.h usability... no
checking /include/mysql/mysql.h presence... no
checking for /include/mysql/mysql.h... no
Configuration error:
could not find the MySQL installation include and/or library
directories. Manually specify the location of the MySQL
libraries and the header files and re-run R CMD INSTALL.
INSTRUCTIONS:
1. Define and export the 2 shell variables PKG_CPPFLAGS and
PKG_LIBS to include the directory for header files (*.h)
and libraries, for example (using Bourne shell syntax):
export PKG_CPPFLAGS="-I<MySQL-include-dir>"
export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"
Re-run the R INSTALL command:
R CMD INSTALL RMySQL_<version>.tar.gz
2. Alternatively, you may pass the configure arguments
--with-mysql-dir=<base-dir> (distribution directory)
or
--with-mysql-inc=<base-inc> (where MySQL header files reside)
--with-mysql-lib=<base-lib> (where MySQL libraries reside)
in the call to R INSTALL --configure-args='...'
R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/usr/lib64/R/library/RMySQL’
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmpz2Q4Wl/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
You do need to install mysql-devel. Please see step 3 of QuickStart Guide for R on InfiniDB website. It states the following:
Install a MySQL developer library on the client machine. Available from http://www.mysql.com and http://dev.mysql.com or you can use a package installer like apt-get. If you already installed a MySQL server, make sure that client header and library files are included in the install.
Example in Ubuntu:
sudo apt-get install mysql-client libmysqlclient-dev
Example in CentOS
sudo yum install mysql mysql-devel
If you have further questions please feel free to post in the InfiniDB forum as well.
I found a solution of sort.
First of all, my premise was to be able to use RMySQL with InfiniDB without adding a MySQL installation to the mix.
(As per wikipedia) "InfiniDB is accessed through a MySQL interface".
A recent paper on InfiniDB website on R and InifiniDB ("R Statistical Computing Quick Start Guide") listed simple instructions to install and use InfiniDB in R with RMySQL without mentioning any pre-requisite.
I found this to be incorrect. Within my CENTOS installation I wasn't able to compile the RMySQL package. The missing mysql.h was preventing it.
The solution I found was to install mysql-devel with yum. Yum installed also mysql client programs and shared libraries as a dependency.
On the other hand the total install with yum was 3MB and I can still say I didn't need MySQL server installed (at least!) as RMySQL+InfiniDB need just the MySQL libraries to work.

Installation of package ncdf fails due to missing header although it's there

I'm trying to install the r package ncdf on an Ubuntu 10.04 server:
install.packages("ncdf", type = "source")
Installing package into ‘/home/me/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/ncdf_1.6.6.tar.gz'
Content type 'application/x-gzip' length 79403 bytes (77 Kb)
opened URL
==================================================
downloaded 77 Kb
* installing *source* package ‘ncdf’ ...
** package ‘ncdf’ successfully unpacked and MD5 sums checked
checking for nc-config... no
checking for gcc... gcc -std=gnu99
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 gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking netcdf.h usability... no
checking netcdf.h presence... no
checking for netcdf.h... no
configure: error: netcdf header netcdf.h not found
ERROR: configuration failed for package ‘ncdf’
* removing ‘/home/me/R/x86_64-pc-linux-gnu-library/3.0/ncdf’
Warning in install.packages :
installation of package ‘ncdf’ had non-zero exit status
I also downloaded the source package and tried to install in the shell, but got the same result.
wget http://cran.r-project.org/src/contrib/ncdf_1.6.6.tar.gz
R CMD INSTALL ncdf_1.6.6.tar.gz
Obviously, the installer doesn't find the correct header file. So I searched the file manually and found it:
root#fourier:/usr/include# ls -ahl netcdf.h
-rw-r--r-- 1 root root 30K 2009-12-22 04:47 netcdf.h
Packages netcdf-bin, netcdf-dbg, netcdf-doc, libnetcdf-dev and libnetcdf4 are all properly installed. apt-get is up to date. This is my session info:
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.0.1
How can I persuade the R installer to use the header file located under /usr/include?
You need to look at the configure.in script to see exactly what it tests for. Maybe it is expecting netcdf.h in a subdirectory rather than directly in /usr/include.
I think I have built this in the past. I could take another look later.
Without downloading source, you just need to set some environment variables. For me, this was
export NETCDF_INCLUDE=/usr/include
After doing this, install.packages("ncdf") worked.
This is described in the INSTALL file.

Resources