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?
Related
I'm trying to install the package, rugarch, for a class.
I am using MacOS Mojave 10.14.6 (18G3020).
I am using RStudio:
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Most of the forums I searched on report the need for Xquartz, but I already have installed it.
I also and searched through
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos-before-r-3.6.0/
Wondering what to try next. I'm thinking the problem has to do with my file path, which may have been mucked up from installing both clang4 and clang6?......
Error message below involves a compiler issue: 'make: *** [RcppArmadillo.o] Error 127'.
Thanks for your help!
> install.packages('rugarch')
also installing the dependency ‘RcppArmadillo’
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/RcppArmadillo_0.8.600.0.0.tar.gz'
Content type 'application/octet-stream' length 1356993 bytes (1.3 MB)
==================================================
downloaded 1.3 MB
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/rugarch_1.4-0.tar.gz'
Content type 'application/octet-stream' length 2936961 bytes (2.8 MB)
==================================================
downloaded 2.8 MB
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
checking for macOS... configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
found
checking for macOS Apple compiler... not found
checking for clang compiler... found
checking for OpenMP compatible version of clang... found and suitable
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... found and suitable
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/Rcpp/include" -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include -I../inst/include -fopenmp -fPIC -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include -c RcppArmadillo.cpp -o RcppArmadillo.o
/bin/sh: /usr/local/clang4/bin/clang++: No such file or directory
make: *** [RcppArmadillo.o] Error 127
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/RcppArmadillo’
Warning in install.packages :
installation of package ‘RcppArmadillo’ had non-zero exit status
ERROR: dependency ‘RcppArmadillo’ is not available for package ‘rugarch’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/rugarch’
Warning in install.packages :
installation of package ‘rugarch’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/bm/wg7t4j8j3tz_88yfzyfdkkhm0000gn/T/RtmpvkSK0v/downloaded_packages’
This question already has answers here:
Cannot compile R packages with c++ code after updating to macOS Catalina
(2 answers)
Closed 3 years ago.
I followed the steps in R Compiler Tools for Rcpp on macOS (for R 3.6.x), but an error occurs when I try to install RcppArmadillo. I don't have Xcode.app install, and prefer to use the command line tools instead.
The answers posted here didn't help :(
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** using staged installation
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++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... clang++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ -std=gnu++11 accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... not found
checking for clang compiler... found
checking for OpenMP compatible version of clang... found and suitable
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... missing
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I"/usr/local/Cellar/r/3.6.1_1/lib/R/include" -DNDEBUG -I"/usr/local/lib/R/3.6/site-library/Rcpp/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -I../inst/include -fPIC -g -O2 -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from RcppArmadillo.cpp:22:
In file included from ../inst/include/RcppArmadillo.h:31:
In file included from ../inst/include/RcppArmadilloForward.h:26:
In file included from /usr/local/lib/R/3.6/site-library/Rcpp/include/RcppCommon.h:29:
In file included from /usr/local/lib/R/3.6/site-library/Rcpp/include/Rcpp/r/headers.h:59:
In file included from /usr/local/lib/R/3.6/site-library/Rcpp/include/Rcpp/platform/compiler.h:100:
In file included from /usr/local/clang7/include/c++/v1/cmath:305:
/usr/local/clang7/include/c++/v1/math.h:301:15: fatal error: 'math.h' file not found
#include_next <math.h>
^~~~~~~~
1 error generated.
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/usr/local/lib/R/3.6/site-library/RcppArmadillo’
* restoring previous ‘/usr/local/lib/R/3.6/site-library/RcppArmadillo’
The downloaded source packages are in
‘/private/var/folders/ny/f06ns0d568bgf6s559z8j_9m0000gn/T/Rtmp0t1pHj/downloaded_packages’
Warning message:
In install.packages("RcppArmadillo") :
installation of package ‘RcppArmadillo’ had non-zero exit status
A side note mentioned in this answer saved me. The trick is to add the following line to $(R RHOME)/etc/Makeconf
CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include
I am trying to install RQuantLib on a Mac OSX 10.13. I have the latest version of R: Version 3.4.3.
I have done the following pre requisites using homebrew
brew install boost
brew install quantlib
However, when I try
install.packages("RQuantLib", configure.args="--with-boost include=/usr/local/include/ --with-boost-lib=/usr/local/lib/")
R returns
* 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... yes
checking for minimal Boost version... yes
configure: creating ./config.status
config.status: creating src/Makevars
Completed configuration and ready to build.
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG
-I"/Users/rorymcstay/Library/R/3.4/library/Rcpp/include" -
I/usr/local/include -Wall -g -O2 -
I/usr/local/Cellar/quantlib/1.12/include -I/usr/local/include/ -
I../inst/include -I. -fopenmp -DRCPP_NEW_DATE_DATETIME_VECTORS -fPIC -
Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang: error: unsupported option '-fopenmp'
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘RQuantLib’
* removing ‘/Users/rorymcstay/Library/R/3.4/library/RQuantLib’
Warning in install.packages :
installation of package ‘RQuantLib’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/mf/7p4rjjq53zg5_3bdqznb9p2h0000gn/T/RtmpsowkET/do wnloaded_packages’
Can anyone see what is going wrong?
Thanks
Rory
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.
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