failed installation of openssl in R SUSE - r

I am a newcomer and currently trying to install openssl package in R (I have a SUSE Linux Enterprise server SP3 distribution), but it fails. The error message is this:
During startup - Warning message:
Setting LC_CTYPE failed, using "C"
* installing *source* package 'openssl' ...
** package 'openssl' successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=
Using PKG_LIBS=-lssl -lcrypto
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pig-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package 'openssl'
I made sure to have installed openssl in SUSE:
OpenSSL 0.9.8j-fips 07 Jan 2009
built on: Mon May 2 15:55:35 UTC 2016
platform: linux-x86_64
options: bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,4,long) blowfish(ptr2)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -
DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DMD32_REG_T=int -fmessage-length=0 -O2
-Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-
unwind-tables -g -fomit-frame-pointer -fno-strict-aliasing -DTERMIO -DPURIFY -
Wall -fstack-protector -Wa,--noexecstack -fprofile-use -DOPENSSL_BN_ASM_MONT
- DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM
OPENSSLDIR: "/etc/ssl"
And the openssl.pc file is located here:
/home/oscar/anaconda_ete/pkgs/openssl-1.0.2g-0/lib/pkgconfig/openssl.pc
/home/oscar/anaconda_ete/lib/pkgconfig/openssl.pc
/etc/ssl/openssl.pc
/usr/lib64/pkgconfig/openssl.pc
I would be very grateful with any help you could provide. I have been stuck for days trying to solve this problem without any success. Thanks a lot.
P.S.: I am installing this packages (openssl) because it is required by another R package (BioGeoBEARS).

You can't install a newer version than 0.9.8 on SLES 11 because the next openssl version is incompatible with itself.
https://www.suse.com/communities/blog/tls-1-2/
https://www.openssl.org/news/changelog.html#x37
But there is a possibility to build and install openssl 1.0.2 on SLES11 in an additional folder and point the r-openssl package to it.
Download and extract openssl src tarball
cd ~
curl https://www.openssl.org/source/openssl-1.1.0f.tar.gz | tar zxv
Create a new directory for the additional openssl version
e.g.
sudo mkdir -p /opt/R/extra/openssl
build and install openssl 1.1.0 with prefix
cd openssl-1.1.0f
./configure --prefix=/opt/R/extra/openssl
make
sudo make install
install r-package openssl (0.9.7)
cd ~
R CMD INSTALL --configure-vars='INCLUDE_DIR=/opt/R/extra/openssl/include LIB_DIR=/opt/R/extra/openssl/lib' openssl_0.9.7.tar.gz

Related

ERROR: configuration failed for package ‘ragg’

> install.packages("ragg")
trying URL 'https://cloud.r-project.org/src/contrib/ragg_1.1.3.tar.gz'
Content type 'application/x-gzip' length 420401 bytes (410 KB)
==================================================
downloaded 410 KB
Welcome at Tue Aug 17 23:24:09 2021
Library path: /home/roy/miniconda3/envs/r-4.1/lib/R/library
Repositories set.
R_MAX_NUM_DLLS set to 1000.
* installing *source* package ‘ragg’ ...
** package ‘ragg’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu
Using PKG_LIBS=-lfreetype -lpng16 -lm -lz -lm -lz -ltiff -lwebp -lzstd -llzma -ljbig -ljpeg -lz -lm
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find one of freetype2 libpng libtiff-4. Try installing:
* deb: libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev (Debian, Ubuntu, etc)
* rpm: freetype-devel libpng-devel libtiff-devel libjpeg-turbo-devel (Fedora, CentOS, RHEL)
* csw: libfreetype_dev libpng16_dev libtiff_dev libjpeg_dev (Solaris)
If freetype2 libpng libtiff-4 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a freetype2 libpng libtiff-4.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
In file included from /home/roy/miniconda3/envs/r-4.1/x86_64-conda-linux-gnu/sysroot/usr/include/features.h:361,
from /home/roy/miniconda3/envs/r-4.1/x86_64-conda-linux-gnu/sysroot/usr/include/limits.h:27,
from /home/roy/miniconda3/envs/r-4.1/lib/gcc/x86_64-conda-linux-gnu/9.3.0/include-fixed/limits.h:194,
from /home/roy/miniconda3/envs/r-4.1/lib/gcc/x86_64-conda-linux-gnu/9.3.0/include-fixed/syslimits.h:7,
from /home/roy/miniconda3/envs/r-4.1/lib/gcc/x86_64-conda-linux-gnu/9.3.0/include-fixed/limits.h:34,
from /usr/include/libpng16/pngconf.h:31,
from /usr/include/libpng16/png.h:339,
from <stdin>:2:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:492:49: error: missing binary operator before token "("
492 | #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
| ^
In file included from /home/roy/miniconda3/envs/r-4.1/x86_64-conda-linux-gnu/sysroot/usr/include/stdio.h:932,
from /usr/include/libpng16/pngconf.h:46,
from /usr/include/libpng16/png.h:339,
from <stdin>:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:228:17: error: missing binary operator before token "("
228 | #if __GLIBC_USE (DEPRECATED_GETS)
| ^
--------------------------------------------------------------------
ERROR: configuration failed for package ‘ragg’
* removing ‘/home/roy/miniconda3/envs/r-4.1/lib/R/library/ragg’
The downloaded source packages are in
‘/tmp/RtmpL1ZZnL/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("ragg") :
installation of package ‘ragg’ had non-zero exit status
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.1.0 (2021-05-18)
#> os Ubuntu 20.04.2 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language en_GB:en
#> collate en_GB.UTF-8
#> ctype en_GB.UTF-8
#> tz Europe/Stockholm
#> date 2021-08-17
This issue happens in a conda environment. The suggested linux libraries are installed (see below, run in the same conda env).
sudo apt-get install -y libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libjpeg-dev is already the newest version (8c-2ubuntu8).
libpng-dev is already the newest version (1.6.37-2).
libfreetype6-dev is already the newest version (2.10.1-2ubuntu0.1).
libtiff5-dev is already the newest version (4.1.0+git191117-2ubuntu0.20.04.1).
0 to upgrade, 0 to newly install, 0 to remove and 26 not to upgrade.
ragg installation outside the conda env works fine. My guess is that when installing from the conda env, it doesn't find the path to something. Any tips?
It looks like something connected to this question answer. I encountered the same issue when was trying to install "ragg" package inside my conda env, and the suggested fix in the log (mentioned by #BlackBear answer) is not the real cause of the issue, the issue's cause is showed below in the log:
-------------------------- [ERROR MESSAGE] ---------------------------
In file included from /home/roy/miniconda3/envs/r-4.1/x86_64-conda-linux-gnu/sysroot/usr/include/features.h:361,
from /home/roy/miniconda3/envs/r-4.1/x86_64-conda-linux-gnu/sysroot/usr/include/limits.h:27,
from /home/roy/miniconda3/envs/r-4.1/lib/gcc/x86_64-conda-linux-gnu/9.3.0/include-fixed/limits.h:194,
from /home/roy/miniconda3/envs/r-4.1/lib/gcc/x86_64-conda-linux-gnu/9.3.0/include-fixed/syslimits.h:7,
from /home/roy/miniconda3/envs/r-4.1/lib/gcc/x86_64-conda-linux-gnu/9.3.0/include-fixed/limits.h:34,
from /usr/include/libpng16/pngconf.h:31,
from /usr/include/libpng16/png.h:339,
from <stdin>:2:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:492:49: error: missing binary operator before token "("
492 | #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
| ^
In file included from /home/roy/miniconda3/envs/r-4.1/x86_64-conda-linux-gnu/sysroot/usr/include/stdio.h:932,
from /usr/include/libpng16/pngconf.h:46,
from /usr/include/libpng16/png.h:339,
from <stdin>:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:228:17: error: missing binary operator before token "("
228 | #if __GLIBC_USE (DEPRECATED_GETS)
| ^
--------------------------------------------------------------------
And it is maybe somehow connected to macros definition confusing. I'm not a big specialist in glibc and other things, for me the suggestion from the #MrFlick in comments to the question to install package directly via conda worked (mamba install -c conda-forge r-ragg)
The solution is in the log:
Configuration failed to find one of freetype2 libpng libtiff-4. Try installing:
* deb: libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev (Debian, Ubuntu, etc)
* rpm: freetype-devel libpng-devel libtiff-devel libjpeg-turbo-devel (Fedora, CentOS, RHEL)
* csw: libfreetype_dev libpng16_dev libtiff_dev libjpeg_dev (Solaris)
Install those packages and try again.
I saw the same error. The fix is to install pkg-config to the conda environment:
conda install -c conda-forge pkg-config
Somehow it seems that R c compiler under conda environment can not call system pkg-config correctly.

Cannot install Rstan 2.21 library on CentOS 7 R 4.0.1

I cannot install the latest version of Rstan using R4.0.1 on CentOS 7 machine.
I followed the instructions found here: https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux
I do not have admin rights to the linux server, so I am wondering if this means I need to ask admin to install V8?
If so, which version - the brew version? (Im not very linux literate).
Any help very much appreciated.
Here is the error:
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find the libv8 engine library. Try installing:
deb: libv8-dev or libnode-dev (Debian / Ubuntu)
rpm: v8-devel (Fedora, EPEL)
brew: v8 (OSX)
csw: libv8_dev (Solaris)
To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars=‘INCLUDE_DIR=… LIB_DIR=…’
---------------------------[ ERROR MESSAGE ]----------------------------
:1:10: fatal error: v8.h: No such file or directory
compilation terminated.
ERROR: configuration failed for package ‘V8’
removing ‘/home/jjannot/R/x86_64-pc-linux-gnu-library/4.0/V8’
ERROR: dependency ‘V8’ is not available for package ‘rstan’
removing ‘/home/jjannot/R/x86_64-pc-linux-gnu-library/4.0/rstan’
The downloaded source packages are in
‘/tmp/RtmpsiiC9D/downloaded_packages’
Warning messages:
1: In install.packages(“rstan”, type = “source”) :
installation of package ‘V8’ had non-zero exit status
2: In install.packages(“rstan”, type = “source”) :
installation of package ‘rstan’ had non-zero exit status
The details/specs:
Operating System - CentOS 7
RStan Version - 2.21
Output of
writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=/usr/bin/g++
CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=/opt/rh/devtoolset-7/root/usr/bin/g++
CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=g++
Output of
devtools::session_info("rstan")─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 4.0.1 (2020-06-06)
os CentOS Linux 7 (Core)
system x86_64, linux-gnu
ui X11
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Los_Angeles
date 2020-09-01
─ Packages ───────────────────────────────────────────────────────────────────
! package * version date lib source
R rstan [?]
[1] /home/jjannot/R/x86_64-pc-linux-gnu-library/4.0
[2] /opt/R/64-bit/R-4.0.1/lib64/R/library
R ── Package was removed from disk.
Here is the complete solution in case it can help someone else.
On CentOS 7:
installed V8 headers and shared library from here: https://pkgs.org/download/v8-devel (EPEL_x86_64)
bumped gcc (g++) from version 4 to 9.3.1
In R:
removed rstan and StanHeaders
installed in a fresh R session

How to install Tidyverse on Ubuntu 16.04 and 17.04

I'm running Ubuntu 16.04 [now 17.04: see note in bold below] and R 3.4.1. I installed the latter this morning, so I presume it's the latest version. I want to install Tidyverse, which I've spent many happy hours with under Windows. But when I do install.packages("tidyverse") , I get errors about unrecognized command line options to gcc. These start when the install hits the colorspace and munsell packages. I'll show an example at the end of this post, just for munsell.
I've not found anyone else who had exactly that problem on Ubuntu 16.04. But posts from people with similar problems suggest that my gcc might be a version that's too old to recognise the options -fstack-protector-strong and -Wdate-time.
Possible work-arounds that I've thought of:
1) Update Ubuntu to 16.10 or 17.04 in the hope that one of these has a suitable gcc. However, I'm hitting my lack of Ubuntu expertise here: in particular, it appears that I have to upgrade twice, once to 16.10 and then again to 17.04. I can't even make the system upgrade to 16.10: the steps recommended at https://wiki.ubuntu.com/YakketyYak/ReleaseNotes , "Upgrading from Ubuntu 16.04 LTS", don't find upgrades when I try them. Also, I don't know for sure whether either of those Ubuntus would have the right gcc.
Added the following day: Although my attempts to upgrade Ubuntu by following https://wiki.ubuntu.com/YakketyYak/ReleaseNotes did nothing yesterday, they did work today. Maybe a caching problem? So I now have Ubuntu 17.04. However, I still get the same errors when trying to install Tidyverse.
2) Find an older version of Tidyverse that doesn't need those compiler options.
3) Upgrade my Ubuntu's gcc. But I don't know whether that would nuke other software on my machine that expects an older gcc.
4) Install a new gcc just for Tidyverse, and somehow play with paths to fool the installer into calling it, perhaps by following the advice in https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu . But that sounds risky.
5) Scrap Ubuntu and do all my work on Windows. I know people deride "Micro$oft", but at least with Windows, I don't waste a morning with Linux arcana and can do my job, which is R. This is feeling far too much like the priests with their incantations in https://people.dsv.su.se/~jpalme/s1/hoare.pdf , "Software Design: a Parable". Just saying...
Any suggestions from someone who has actually done this with these versions of R and Ubuntu?
Here's an install that failed:
`> install.packages("munsell")
Installing package into ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘colorspace’
trying URL 'https://cran.rstudio.com/src/contrib/colorspace_1.3-2.tar.gz'
Content type 'application/x-gzip' length 293433 bytes (286 KB)
==================================================
downloaded 286 KB
trying URL 'https://cran.rstudio.com/src/contrib/munsell_0.4.3.tar.gz'
Content type 'application/x-gzip' length 97244 bytes (94 KB)
==================================================
downloaded 94 KB
* installing *source* package ‘colorspace’ ...
** package ‘colorspace’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c colorspace.c -o colorspace.o
gcc: error: unrecognized command line option '-fstack-protector-strong'
gcc: error: unrecognized command line option '-Wdate-time'
/usr/lib/R/etc/Makeconf:159: recipe for target 'colorspace.o' failed
make: *** [colorspace.o] Error 1
ERROR: compilation failed for package ‘colorspace’
* removing ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4/colorspace’
Warning in install.packages :
installation of package ‘colorspace’ had non-zero exit status
ERROR: dependency ‘colorspace’ is not available for package ‘munsell’
* removing ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4/munsell’
Warning in install.packages :
installation of package ‘munsell’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpQ8FW70/downloaded_packages’
Warning message:
R graphics engine version 12 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
In some cases I find that I need to install the Ubuntu packages. To install the Tidyverse I added
sudo apt-get install r-cran-curl r-cran-openssl r-cran-xml2
After installing these packages, I could install the Tidyverse.
I run into the same problem, using elementary loki, based on ubuntu 16.04. Reading the output, I realized there was a very informative error message, that looked like this
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl#1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
So I followed each prompt, installing the required deb, which came up to
sudo apt-get install libssl-dev libxml2-dev libcurl4-openssl-dev
and it worked, after I had already tried installing the cran packages listed above, without adding the new repositories.
I believe had a similar problem trying to install the tidyverse package.
Being reasonably new to Linux and a complete rookie to R, I followed the Ubuntu installation intructions on the CRAN Project's homepage. When I installed R, I deliberately skipped installation of the r-base-dev package, as it said it was intended for "package maintainers". I didn't really read the latter part or understand the necessity for compiling packages myself.
Anyway, installing r-base-dev package, and allowed me to install the Tidyverse package without problems. The complete steps to get it to work should be something like below. In terminal do the following steps (Step 1-3 may or may not be necessary, but I've added them just in case):
Add deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu artful/ in your /etc/apt/sources.list file, replacing by the actual URL of your favorite CRAN mirror. See https://cran.r-project.org/mirrors.html for the list of CRAN mirrors.
Add the repository key to your system:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
An alternate method can be used by retrieving the key with
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
and then feed it to apt-key with
gpg -a --export E084DAB9 | sudo apt-key add -
To install the complete R system, use
sudo apt-get update
sudo apt-get install r-base
Then comes the step I missed, that proved crucial to be able to compile the packages within the Tidyverse package, namely installing the r-base-dev package:
sudo apt-get install r-base-dev
Then in RStudio execute the package installation command:
install.packages(tidyverse)
Hopefully this will work for you as well. Read the installation guide on the CRAN Projects homepages for further about the installation procedure.
Add CRAN repo
https://cloud.r-project.org/bin/linux/ubuntu/
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
sudo apt-get r-cran-tidyverse
Then you're installing tidyverse from binary rather than compiling 100 times quicker.

Correct fftw installation enabling Rcartogram

I would like to instal FFTW to enable the Rcartogram package.
Attempts
homebrew
After installing fftw libraries via homebrew:
brew install fftw --with-fortran --with-mpi --with-openmp --enable-float
The attempt to install the Rcartogram fails with the following error:
>> devtools::install_github("omegahat/Rcartogram")
Downloading GitHub repo omegahat/Rcartogram#master
from URL https://api.github.com/repos/omegahat/Rcartogram/zipball/master
Installing Rcartogram
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ \
--no-save --no-restore --quiet CMD INSTALL \
'/private/var/folders/7x/kwc1y_l96t55_rwlv35mg8xh0000gn/T/Rtmp7nMfM9/devtoolsa9f2458e68c3/omegahat-Rcartogram-715cb93' \
--library='/Users/whereIkeepMyStuff' --install-tests
* installing *source* package ‘Rcartogram’ ...
(...)
Can compile with fftw3.h
checking for fftw_malloc in -lfftw3... no
configure: error: "cannot link to libfftw3"
ERROR: configuration failed for package ‘Rcartogram’
* removing (...)
Error: Command failed (1)
make install
As a second approach I tried the guidelines available here and install FFTW using the following syntax:
wget http://www.fftw.org/fftw-3.3.6-pl1.tar.gz
tar -xvzf fftw-3.3.6-pl1.tar.gz
cd fftw-3.3.6-pl1
./configure --prefix=/usr/local/fftw-3.6.6 --enable-threads \
--enable-float --enable-shared \
CC="gcc -arch i386 -arch x86_64" CXX="g++ -arch i386 -arch x86_64" \
CPP="gcc -E" CXXCPP="g++ -E" F77=gfortran
make
sudo make install
sudo ln -s /usr/local/fftw-3.6.6 /usr/local/fftw
This fails as follows:
>> devtools::install_github("omegahat/Rcartogram")
(...)
* installing *source* package ‘Rcartogram’ ...
checking for pkg-config... /usr/local/bin/pkg-config
Package fftw3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `fftw3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fftw3' found
Package fftw3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `fftw3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fftw3' found
Looking for fftw3 files in /usr/local
Cannot find fftw.h
ERROR: configuration failed for package ‘Rcartogram’
Configuration
OS
sw_vers -productVersion
10.12.2
R
R --version
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)
How can install FFTW so I could use the Rcartogram package?
Cleaning
After failed attempts I would clean:
homebrew
brew uninstall fftw
shell
sudo make uninstall
sudo rm -rv /usr/local/fftw*

Installing nloptr on Linux

I am trying to install the R package nloptr on a CentOS Linux machine that doesn't have internet connection as follows:
install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
This command in turn looks for the following file online
http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz
However, this fails since there is no internet connection to the machine.
I tried the suggestion from the following stackoverflow post:
trouble with Installing nloptr by locally on Ubuntu
I changed the URL in configure and configure.ac files as follows:
NLOPT_URL="file:///home//ravi//${NLOPT_TGZ}"
However, I get the following error when I try to install the package again:
> install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
* installing *source* package 'nloptr' ...
files 'configure', 'configure.ac' have the wrong MD5 checksums
ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'
* removing '/opt/vertica/R/library/nloptr'
Warning message:
In install.packages("/home/ravi/nloptr_1.0.4.tar.gz", :
installation of package '/home/ravi/nloptr_1.0.4.tar.gz' had non-zero exit status
Can someone guide me on how to install this R package locally?
Update 1
Based on the suggestion from Dirk on installing nlopt first, I followed the instructions given in the following page:
http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
I installed nlopt as follows :
./configure --enable-shared
make
make install
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
When I tried to re-install nloptr in R, it doesn't look for the nlopt link anymore but throws the following error:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/opt/vertica/R/library/nloptr/libs/nloptr.so':
/opt/vertica/R/library/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/opt/vertica/R/library/nloptr'
Warning message:
In install.packages("/home/ravi/nloptr_1.0.4.tar.gz", :
installation of package '/home/ravi/nloptr_1.0.4.tar.gz' had non-zero exit status
Update 2
As suggested by Dirk, I looked into the ldconfig command and used the following reference:
http://codeyarns.com/2014/01/14/how-to-add-library-directory-to-ldconfig-cache/
I edited the /etc/ld.so.conf file, added the directory /usr/local/lib which contains the shared library and ran the ldconfig command. This added the relevant shared library as shown below:
libnlopt.so.0 (libc6,x86-64) => /usr/local/lib/libnlopt.so.0
libnlopt.so (libc6,x86-64) => /usr/local/lib/libnlopt.so
However, when I tried reinstalling the nloptr package, I still get the same shared object error.
Could someone guide me on the shared library error?
When you say [t]his command in turn looks for the following file online you only get half the story. Together with Jelmer, the maintainer of the actual nloptr package, I modified the package to do the following:
look for an install libnlopt library, and, if found, use it
if not found fall back to the old behaviour and download the library
So you could simply install nlopt via
sudo apt-get install libnlopt-dev
(or the equivalent sudo dpkg -i /media/.... pointing to the file from a
USB drive etc pp) and then reinstall the nloptr package. It will just work. On my machine:
edd#max:~$ install.r nloptr ## install.r is in littler
trying URL 'http://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/x-gzip' length 353942 bytes (345 KB)
==================================================
downloaded 345 KB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ 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 pkg-config... yes
configure: Now testing for NLopt header file.
[...]
checking for nlopt.h... yes
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -O3 -Wall -pipe -Wno-unused -pedantic -c dummy.cpp -o dummy.o
gcc -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -O3 -Wall -pipe -pedantic -std=gnu99 -c nloptr.c -o nloptr.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so dummy.o nloptr.o -lnlopt -lm -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/nloptr/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (nloptr)
The downloaded source packages are in
‘/tmp/downloaded_packages’
edd#max:~$
Note how it compiled only two files from the actual R packages having found the nlopt installation.
I had exactly the same problem, on a production machine without direct Internet access, with Red Hat Enterprise Linux Server release 6.6 (Santiago). The fixups proposed above did not work: when installing the nlopt library on the system, the subsequent attempt to install nloptr fail with the "nlopt_set_maxtime" error. I tried to fiddle with compilation options for nlopt, to no avail. I even reproduced the problem on a Ubuntu machine with Internet connection: I uninstalled nloptr, installed nlopt on the system and then the nloptr installation failed.
At last I solved the issue taking the following steps:
Un-install nlopt from the operating system (make sure that it is thoroughly removed).
Manually download nlopt-2.4.2.tar.gz and copy it to /tmp/
Manually download nloptr_1.0.4.tar.gz to a work directory and unpack it; this creates the directory "nloptr/".
Edit "nloptr/configure", comment out the row
$("${R_HOME}/bin/Rscript" --vanilla -e
"download.file(url='${NLOPT_URL}', destfile='${NLOPT_TGZ}')")
and insert a new row:
$("${R_HOME}/bin/Rscript" --vanilla -e
"file.copy(from='/tmp/nlopt-2.4.2.tar.gz', to='${NLOPT_TGZ}')")
Install with "R CMD INSTALL nloptr".
I had a similar problem on Ubuntu. In addition to installing nlopt-dev as Dirk answered, I also had to install pkg-config:
sudo apt-get install pkg-config
Hope this helps.
If you are on CentOS (and have internet access, but the nlopt server is not reachable), you can install nlopt first using
yum install nlopt nlopt-devel
Then you can install nloptr normally.
I had the same issue setting up nloptr on my RHEL 7.2 instance. For those using RHEL you can do the following:
Download & install the following RPMS in the same order:
NLopt-2.4.2-2.el7.x86_64.rpm- https://pkgs.org/centos-7/epel-x86_64/NLopt-2.4.2-2.el7.x86_64.rpm.html
NLopt-devel-2.4.2-2.el7.x86_64.rpm - https://pkgs.org/centos-7/epel-x86_64/NLopt-devel-2.4.2-2.el7.x86_64.rpm.htm
Please note that these RPMs may need additional dependencies to be installed based on your system configuration.
Post this you can install nloptr directly using the install.packages utility or download source from CRAN and install from source as suggested in earlier responses.
Hope this helps!
Kiran
if you are using AWS Linux the below should help
yum --enablerepo=epel install NLopt-devel -y
I just solved this on my server with following two steps:
Install libnlopt-dev and nlopt with
sudo apt-get install libnlopt-dev
pip install nlopt
Use sudo R to launch R and type:
withr::with_makevars(c(PKG_LIBS='-lnlopt'),install.packages('nloptr'),assignment='+=')
I think I have the same problem as you and I am using CentOS 6.5
Remove nlopt and install nloptr with install.packages() in R, a nlopt will be installed automatically.
I removed installed nlopt with the following command in the unzipped nlopt folder.
make uninstall
If you had tried to use epel repository in CentOS and had installed nlopt with yum, try:
yum remove nlopt
After removing existed nlopt, I am able to install nloptr with
install.packages("nloptr")

Resources