I can't install the package nloptr 1.0.4 on R 3.3.0. The messages are the following:
> install.packages("nloptr")
Installing package into ‘/Users/fgomesbarros/Library/R/3.3/library
(as ‘lib’ is unspecified)
trying URL 'https://cran.revolutionanalytics.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/octet-stream' 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 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 nlopt.h usability... yes
checking nlopt.h presence... yes
checking for nlopt.h... yes
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/bin/clang++ -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/opt/local/include -fPIC -pipe -Os -arch x86_64 -stdlib=libstdc++ -c dummy.cpp -o dummy.o
/usr/bin/clang -I/opt/local/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/opt/local/include -fPIC -pipe -Os -arch x86_64 -c nloptr.c -o nloptr.o
/usr/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -L/opt/local/lib -Wl,-headerpad_max_install_names -o nloptr.so dummy.o nloptr.o -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/fgomesbarros/Library/R/3.3/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
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so':
dlopen(/Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
Referenced from: /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
Expected in: flat namespace
in /Users/fgomesbarros/Library/R/3.3/library/nloptr/libs/nloptr.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
* restoring previous ‘/Users/fgomesbarros/Library/R/3.3/library/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/rz/dp6vmb39165406h9qv69q60c0000gn/T/RtmpLvLOmn/downloaded_packages’`
My R version is 3.3.0 as you can see below:
> version
_
platform x86_64-apple-darwin12.6.0
arch x86_64
os darwin12.6.0
system x86_64, darwin12.6.0
status
major 3
minor 3.0
year 2016
month 05
day 03
svn rev 70573
language R
version.string R version 3.3.0 (2016-05-03)
nickname Supposedly Educational
Any clues?
I also tried to install in olders versions (2.3.3 and 2.3.4) of R and had the same issue.
Thanks in advance.
I was able to solve the problem on my Mac using
$ brew install nlopt
Looking into the issue I noticed that others had reportedly resolved the issue on Ubuntu using
$ sudo apt-get install libnlopt-dev
Apparently you now need to install it outside of R.
For me, running CentOS, the missing puzzle piece was this:
sudo yum install nlopt-devel
I tried to reinstall the package as a root and it worked! I don't know why.
If you run into this problem with nloptr 1.2.0 and R 3.5.1 on macOS High Sierra, brew install nlopt will fail because of inadequate permissions in /usr/local. The fix:
$ mkdir /usr/local/Frameworks
$ sudo chown -R $(whoami) /usr/local/Frameworks
$ brew install nlopt
In other words, you don't want to change permissions for the entire /usr/local directory. The installation fails when the Homebrew tries to create /usr/local/Framework. So, do it by hand as shown above. Then try again > install.packages("nloptr"). It worked for me.
I had to reinstall R, using the R-CRAN installer and uninstalling the macports package.
It finally worked!
In my case it was the issue of cmake as i am using ubuntu 22. i was installing matlib package of R and then in dependencies i faced this issue which is solved using
sudo apt-get install cmake
Related
I have been unable to install the R package stringi on my Macbook Pro (running MacOS Monterey) with the new M1 & arm64 architecture. There are a number of posts on SO describing similar problems, but the error message I'm receiving is something I haven't seen before.
When I run install.packages("stringi") in RStudio, I receive the following error message:
stri_brkiter.cpp:60:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
I'm guessing there is some kind of compiler mismatch going on here - there shouldn't be 'undeclared identifier' errors coming from a CRAN package. I'm not sure how to fix the problem, though, and I wasn't able to find any examples online of others getting a similar message. I've seen a lot of similar errors online, but the fixes for those haven't helped me get around this isNull() error.
Note: The lines above are just the error portion of the message output. See below for full error text.
> install.packages("stringi")
Installing package into ‘/Users/<username>/r_libs’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘stringi’
Do you want to attempt to install these from sources? (Yes/no/cancel) yes
installing the source package ‘stringi’
Content type 'application/x-gzip' length 7578882 bytes (7.2 MB)
==================================================
downloaded 7.2 MB
* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
** using staged installation
checking for R_HOME... /Library/Frameworks/R.framework/Resources
checking for R... /Library/Frameworks/R.framework/Resources/bin/R
checking for endianness... little
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... no
checking for cat... /bin/cat
checking for local ICUDT_DIR... icu69/data
checking for gcc... clang -arch arm64
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 -arch arm64 accepts -g... yes
checking for clang -arch arm64 option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -arch arm64 -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 elf.h usability... no
checking elf.h presence... no
checking for elf.h... no
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++11 accepts -g... yes
checking whether the C++ compiler supports the long long type... yes
checking whether the compiler implements namespaces... yes
checking whether the compiler supports Standard Template Library... yes
checking whether std::map is available... yes
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking with pkg-config for the system ICU4C... 70.1
checking for ICU4C >= 55... yes
checking for additional required CPPFLAGS, LDFLAGS, and LIBS... done
checking whether an ICU4C-based project can be built... yes
checking programmatically for sufficient U_ICU_VERSION_MAJOR_NUM... yes
checking programmatically if U_CHARSET_IS_UTF8 is defined and set... yes
checking the capabilities of the ICU data library (ucnv, uloc, utrans)... yes
checking the capabilities of the ICU data library (ucol)... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/uconfig_local.h
config.status: creating src/install.libs.R
*** stringi configure summary:
ICU_FOUND=1
STRINGI_CXXSTD=CXX_STD=CXX11
STRINGI_CFLAGS= -fPIC
STRINGI_CPPFLAGS=-I. -I/opt/homebrew/Cellar/icu4c/70.1/include -UDEBUG -DNDEBUG
STRINGI_CXXFLAGS= -fPIC
STRINGI_LDFLAGS=-L/opt/homebrew/Cellar/icu4c/70.1/lib
STRINGI_LIBS=-licui18n -licuuc -licudata
*** Compiler settings used:
CC=clang -arch arm64
LD=clang++ -arch arm64 -std=gnu++14
CFLAGS=-falign-functions=64 -Wall -g -O2 -fPIC
CPPFLAGS=-I/opt/R/arm64/include -UDEBUG -DNDEBUG
CXX=clang++ -arch arm64 -std=gnu++11
CXXFLAGS=-falign-functions=64 -Wall -g -O2 -fPIC
LDFLAGS=
LIBS=
** libs
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I. -I/opt/homebrew/Cellar/icu4c/70.1/include -UDEBUG -DNDEBUG -I/opt/R/arm64/include -fPIC -fPIC -falign-functions=64 -Wall -g -O2 -c stri_brkiter.cpp -o stri_brkiter.o
stri_brkiter.cpp:60:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
stri_brkiter.cpp:130:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
stri_brkiter.cpp:171:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
3 errors generated.
make: *** [stri_brkiter.o] Error 1
ERROR: compilation failed for package ‘stringi’
* removing ‘/Users/<username>/r_libs/stringi’
* restoring previous ‘/Users/<username>/r_libs/stringi’
The downloaded source packages are in
‘/private/var/folders/qc/whkk090506v2qjy698yf25m80000gq/T/RtmpvLUDID/downloaded_packages’
Warning message:
In install.packages("stringi") :
installation of package ‘stringi’ had non-zero exit status
I've tried installing stringi both in R Studio and on the command line, which some SO posts suggested may be more effective, but I receive the same errors via both methods.
Initially, the compiler was unable to find the ICU4C library (which also prevented me from installing stringi), but I was able to point pkg-config to the library by running brew link icu4c --force and that resolved it.
Other commands I've tried (that did NOT fix it):
install.packages('stringi', configure.args='--disable-cxx11')
install.packages("stringi", configure.args = "--with-extra-cxxflags='--std=c++11'")
Fully removing my Makevars file didn't resolve the issue.
I've checked many of the major/popular related questions on SO & Github (including this, this, this, this, this etc). I think I've reached the edge of my understanding of this stuff, though.
My admittedly non-expert assumption is that this has to do with the compilers I've downloaded, the M1 architecture workarounds I've done, and/or my Makevars file, as I've installed stringi on previous (older) Macbooks before without any issue.
System info:
OS: Mac OS Monterey (v 12.2) w/ an Apple M1 Max chip
R: R version 4.2.0
RStudio: RStudio version 1.4.1717
Xcode: Xcode version 13.3.1
Installed gcc/gfortran and other libraries using Homebrew & added download location to $PATH
My Makevars file:
This file was built based on advice from here, here, here, and here.
CC=/opt/homebrew/bin/gcc-11
CXX=/opt/homebrew/bin/g++-11
FC=/opt/homebrew/bin/gfortran-11
F77=/opt/homebrew/bin/gfortran-11
FLIBS=-L/opt/homebrew/opt/gfortran/lib -lgfortran -lquadmath -lm
CFLAGS=-I/opt/homebrew/include
CXXFLAGS=-O3 -Wall -pipe -Wno-unused -pedantic
CXX11FLAGS=-O3 -Wall -pipe -Wno-unused -pedantic
Does this error look familiar to anyone, or does anyone have suggestions of what I could do next to fix this? I've tried a lot of workarounds so I apologize if I've left anything out, please let me know if any other information could be useful!
Thanks!
For those returning with this same problem, it seems stringi fails to build specifically under R v.4.2.* (see here and here). Downgrading to R v.4.1.1 was sufficient to fix this on my machine, with session info below.
Prior to downgrade:
platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 2.1
year 2022
month 06
day 23
svn rev 82513
language R
version.string R version 4.2.1 (2022-06-23)
nickname Funny-Looking Kid
After downgrade:
platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 1.1
year 2021
month 08
day 10
svn rev 80725
language R
version.string R version 4.1.1 (2021-08-10)
nickname Kick Things
Unless you absolutely need to have source compiled version, there is a binary arm version at the moment. (Obviously people in the future will need to change the version numbers)
install.packages("https://cran.r-project.org/bin/macosx/big-sur-arm64/contrib/4.1/stringi_1.7.6.tgz",
repos = NULL, type = .Platform$pkgType)
I'm wondering if the default repository for Rstudio was not complete in this regard at the point you tried this?
I am trying to install some packages (mailR) to be able to communicate errors and messages to my users by mail, and connecting to HIVE server via rJdbc but installing rJava dependency is getting convoluted more and more as steps are accomplished.
First error is asking for rJava package, so I tried installing rJava:
install.packages("rJava")
Installing package into ‘/home/joe/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-11.tar.gz'
Content type 'application/x-gzip' length 675188 bytes (659 KB)
==================================================
downloaded 659 KB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
** using staged installation
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... 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 -std=gnu99 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/lib/jvm/default-java/bin/java'
archiver : '/usr/bin/jar'
compiler : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags : ''
java libs : ''
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/jmvo/R/x86_64-pc-linux-gnu-library/3.6/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpkTvmz8/downloaded_packages’
So I followed the instructions as root and:
sudo R CMD javareconf
Java interpreter : /usr/lib/jvm/default-java/bin/java
Java version : 11.0.3
Java home path : /usr/lib/jvm/default-java
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-VAQCff/r-base-3.6.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: jni.h: No such file or directory
#include <jni.h>
^~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:167: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /usr/lib/jvm/default-java
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
I´ve checked if I have Open JDK installed because many SO answers seems to be related with absence of JDK.
java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
to be sure, tried installing again JDK with
sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
openjdk-8-jdk is already the newest version (8u212-b03-0ubuntu1.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.
Some other SO answers suggest installing rJava via apt-get this way
sudo apt-get install r-cran-rjava
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
r-cran-rjava : Depends: r-api-3.4
E: Unable to correct problems, you have held broken packages.o
But i`m using R 3.6, so going back is not an option.
Changing to Oracle java is not an option. Many working apps are OpenJDK dependant.
No success so far. This is a never ending process. Tried many SO answers on the matter to no avail.
I need rJava not only for mail but for many other processes like connecting to Hive , and so on... from R.
Thanks
As per much of the advice on SE about getting Mac OS Sierra 10.12.4 to play with rJava nicely, the advice suggests installing from source.
However, when I try and run install.packages("rJava", type = "source") I get an output like so:
> install.packages("rJava", type = "source")
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-8.tar.gz'
Content type 'application/x-gzip' length 656615 bytes (641 KB)
==================================================
downloaded 641 KB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... /usr/local/opt/llvm/bin/clang -fopenmp
checking whether the C compiler works... no
configure: error: in `/private/var/folders/lj/4s8lnxmj4_q8h65zk705k6dr0000gn/T/Rtmp4BrRQs/R.INSTALLd1278e3aab0/rJava':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/lj/4s8lnxmj4_q8h65zk705k6dr0000gn/T/RtmpFhnj89/downloaded_packages’
I've tried updating gcc and gfortran using brew, and also modified my makeconf as specified in answers here and have install xcode.
Update: I believe I have openmp installed via clang, which installed via llvm.
Upate 2: as per hrbrmstrs comment, his file at ~/.R/Makevars differed significantly from mine. Mine was I assume a default:
CC=/usr/local/opt/llvm/bin/clang -fopenmp
CXX=/usr/local/opt/llvm/bin/clang++
LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include
And theirs was:
# shell
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
# ~/.R/Makevars
F77 = /usr/local/gfortran/bin/gfortran
FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CC=ccache /usr/local/opt/gcc/bin/gcc-6 -Wunused-argument
CXX=ccache /usr/local/opt/gcc/bin/g++-6 -Wunused-argument
CXX1X=ccache /usr/local/opt/gcc/bin/g++-6
SHLIB_CXXLD=ccache /usr/local/opt/gcc/bin/g++-6
CCACHE_CPP=yes
CCACHE_CPP2=yes
MAKE=make -j8
Available as a gist too
Output of install.packages("rJava, type = "source") is now
> install.packages("rJava", type = "source")
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-8.tar.gz'
Content type 'application/x-gzip' length 656615 bytes (641 KB)
==================================================
downloaded 641 KB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
/Users/davidparr/.R/Makevars:10: *** missing separator. Stop.
/Users/davidparr/.R/Makevars:10: *** missing separator. Stop.
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... /usr/bin/grep
checking for egrep... /usr/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...
/Users/davidparr/.R/Makevars:10: *** missing separator. Stop.
configure: error: absent
R was configured without Java support. Please run
R CMD javareconf
as root to add Java support to R.
If you do not have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/lj/4s8lnxmj4_q8h65zk705k6dr0000gn/T/Rtmp7beCd4/downloaded_packages’
Now, when I try to run R CMD javareconf -e as suggested (I am not in root user), I get the following in the terminal.
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
ccache /usr/local/opt/gcc/bin/gcc-6 -Wunused-argument -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c conftest.c -o conftest.o
make: ccache: No such file or directory
make: *** [conftest.o] Error 1
Unable to compile a JNI program
I definately have a file gcc-6 in the location specified. Why is the line CXX=ccache /usr/local/opt/gcc/bin/g++-6 -Wunused-argument not CXX=/usr/local/opt/gcc/bin/g++-6?
Running sudo R CMD javareconf with and without -e is more optimistic, though I still don't understand the significance of -e:
Java interpreter : /usr/bin/java
Java version : 1.8.0_131
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on macOS
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
/usr/local/opt/gcc/bin/gcc-6 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c conftest.c -o conftest.o
/usr/local/opt/gcc/bin/gcc-6 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
FWIW, I recently encountered this problem on Mac trying to upgrade from 3.4.x to 3.5.1.
My 3.4.x install had come from https://cran.r-project.org/ but I had used brew install r to upgrade.
install.packages('rJava') was refusing to work with the same error message as here:
configure: error: C compiler cannot create executables
I came here and was skeptical of changing anything in my Makevars because I already had rJava up and running on my machine for about a year on 3.4.x; in fact my .R folder was empty.
I finally concluded that the brew install was the source of my issues (or at least, that some unresolved & hidden mix-up was happening behind the scenes between my old & new installs) & installed from the CRAN website's .pkg file & this issue went away immediately.
Hopefully this experience can be helpful to some others as well.
Every time I try installing RMySQL I get the following error:
Installing package into ‘/home/ehsan/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
* 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... yes
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
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/mysql/mysql.h -fpic -O3 -pipe -g -c RS-DBI.c -o RS-DBI.o
cc1: warning: /usr/include/mysql/mysql.h: not a directory [enabled by default]
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/mysql/mysql.h -fpic -O3 -pipe -g -c RS-MySQL.c -o RS-MySQL.o
cc1: warning: /usr/include/mysql/mysql.h: not a directory [enabled by default]
In file included from RS-MySQL.c:22:0:
RS-MySQL.h:32:19: fatal error: mysql.h: No such file or directory
#include <mysql.h>
^
compilation terminated.
make: *** [RS-MySQL.o] Error 1
ERROR: compilation failed for package ‘RMySQL’
* removing ‘/home/ehsan/R/x86_64-pc-linux-gnu-library/3.0/RMySQL’
The downloaded source packages are in
‘/tmp/RtmpTRRPqg/downloaded_packages’
Warning message:
In install.packages("RMySQL") :
installation of package ‘RMySQL’ had non-zero exit status**
Seemingly, it cannot find mysql.h and I searched and changed the path to
export PKG_CPPFLAGS="-I/usr/R/include/mysql/mysql.h"
but it was not successful. There're many people who have had the same issue but non of their solutions (if existed) worked for me. I'd appreciate any comment or help.
#Update: Issue Resolved#
The following command seemed to solve the issue:
sudo apt-get install r-cran-rmysql
As said, the following command worked for me:
sudo apt-get install r-cran-rmysql
My this issue was resolved by executing the following command:
sudo apt-get install libmysql++-dev
since #ehsanmo hasn't posted his answer as an answer, then I will, and confirm that his solution works for me too:
sudo apt-get install r-cran-rmysql
(I'm on mint 12)
Well, there are two types of install/make problems. Missing .h files and/or missing .so/.a libs. As you can see from your log, you have a missing .h
The reason for these are multiple:
1.- the package that delivers these is not installed. This means that those files cannot be found anywhere in the /usr tree. The solution is to install right package, make sure the files are there
2.- The includes are not found by the install configurator. This means some environment variable or install option is not properly set. Which variable to set is usually specified in the documentation; in some cases you need to install something outside of R and again, that's usually specified in the documentation.
3.- the libs are not in the LD_LIBRARY_PATH, and hopefully the solution to that is self-explanatory.
4.- There is a deeper compile/link error, meaning the package is not compatible with the rest of the sw, or has not been properly ported.
Setp :1
find / -name mysql.h
If not found headers file is missing
Setp :1
Then install or reinstall mysql-devel or mysql-client
sudo yum (re)install mysql-devel
sudo yum (re)install mysql-client
sudo yum (re)install mysql-community-devel
sudo yum (re)install mysql-community-client
I'm trying to install RMySQL in Ubuntu 13.04 when using MySQL v5.6.14. Ubuntu does not have apt-get support for MySQL 5.6.14, so I had to install it manually. Now when I try to install RMySQL I get the following:
(It looks like the package files are not created? But I'm not sure why or how to debug it.)
elad#elad-ThinkPad-T430s:~/tmp$ sudo R CMD INSTALL --configure-args='--with-mysql-inc=/opt/mysql/server-5.6/include --with-mysql-lib=/opt/mysql/server-5.6/lib' RMySQL_0.9-3.tar.gz
* installing to library ‘/usr/local/lib/R/site-library’
* 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
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/opt/mysql/server-5.6/include -fpic -O2 -pipe -g -c RS-DBI.c -o RS-DBI.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/opt/mysql/server-5.6/include -fpic -O2 -pipe -g -c RS-MySQL.c -o RS-MySQL.o
gcc -std=gnu99 -shared -o RMySQL.so RS-DBI.o RS-MySQL.o -L/opt/mysql/server-5.6/lib -lmysqlclient -lz -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/RMySQL/libs
** R
** inst
** preparing package for lazy loading
Creating a generic function for ‘format’ from package ‘base’ in package ‘RMySQL’
Creating a generic function for ‘print’ from package ‘base’ in package ‘RMySQL’
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'RMySQL', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/local/lib/R/site-library/RMySQL/libs/RMySQL.so':
libmysqlclient.so.18: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/RMySQL’
* restoring previous ‘/usr/local/lib/R/site-library/RMySQL’
Update:
This ended up being a LD_LIBRARY_PATH issue. Adding the following to /usr/bin/R solved it:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH/opt/mysql/server-5.6/lib
export LD_LIBRARY_PATH
Did you run ldconfig after installing the library locally?
Does ldconfig -p return something regarding mysql?
On my box, with default MySQL libraries from Ubuntu [lines wrapped by hand]
edd#max:~$ ldconfig -p | grep mysql
libmysqlclient.so.18 (libc6,x86-64) => \
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
libmysqlclient.so (libc6,x86-64) => \
/usr/lib/x86_64-linux-gnu/libmysqlclient.so
edd#max:~$