R-package dll not generated during installation - r

I am writing an example of an R-package that uses C++ to call a C-function from an external library (I used the chron.dll from the R-package chron).
The version of R is R-4.2.2. On my machine (Windows 10) rtools42 is installed in C:/Program Files aka C:/PROGRA~1.
Since this is not the standard location I am running
Sys.setenv(PATH = paste("C:/PROGRA~1/rtools42/bin/", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/")
prior to the build. Then I check the build with devtools::check() and it seems that compilation and linking works but the installation
fails. The 00install.out file is as follows:
* installing *source* package 'PackageExample' ...
** using staged installation
** libs
C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I../chron/include -I. -I'C:/Users/JohnDoe/PROJECTS/R/libraries/Rcpp/include' -I"C:/Programme/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I../chron/include -I. -I'C:/Users/JohnDoe/PROJECTS/R/libraries/Rcpp/include' -I"C:/Programme/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c callchron.cpp -o callchron.o
C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I../chron/include -I. -I'C:/Users/JohnDoe/PROJECTS/R/libraries/Rcpp/include' -I"C:/Programme/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c matrix.cpp -o matrix.o
C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I../chron/include -I. -I'C:/Users/JohnDoe/PROJECTS/R/libraries/Rcpp/include' -I"C:/Programme/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c rcpp_hello_world.cpp -o rcpp_hello_world.o
C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I../chron/include -I. -I'C:/Users/JohnDoe/PROJECTS/R/libraries/Rcpp/include' -I"C:/Programme/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c vector.cpp -o vector.o
C:/PROGRA~1/rtools42/x86_64-w64-mingw32.static.posix/bin/g++ -shared -s -static-libgcc -o PackageExample.dll tmp.def RcppExports.o callchron.o matrix.o rcpp_hello_world.o vector.o -L../chron/libs/x64 -lchron -LC:/Programme/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/Programme/rtools42/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-42~1.2/bin/x64 -lR
installing to C:/Users/JohnDoe/AppData/Local/Temp/Rtmpg9Wn7W/file43d46e066097/PackageExample.Rcheck/00LOCK-PACKAG~1/00new/PackageExample/libs/x64
** R
** byte-compile and prepare package for lazy loading
Reading Tests.R.
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: loading of pakckage or namespace 'PackageExample' in inDL(x, as.logical(local), as.logical(now), ...): failed
cannot load shared object 'C:/Users/JohnDoe/AppData/Local/Temp/Rtmpg9Wn7W/file43d46e066097/PackageExample.Rcheck/00LOCK-PACKAG~1/00new/PackageExample/libs/x64/PackageExample.dll':
LoadLibrary failure: the referenced module was not found.
Error: loading failed
Execution terminated
ERROR: loading failed
* removing 'C:/Users/JohnDoe/AppData/Local/Temp/Rtmpg9Wn7W/file43d46e066097/PackageExample.Rcheck/PackageExample'
(Some error messages translatd from German).
Interestingly the folder
C:/Users/JohnDoe/AppData/Local/Temp/Rtmpg9Wn7W/
contains files foo.dll, foo.o.
It looks like the PackageExample.dll is not put into
'C:/Users/JohnDoe/AppData/Local/Temp/Rtmpg9Wn7W/file43d46e066097/PackageExample.Rcheck/00LOCK- PACKAG~1/00new/PackageExample/libs/x64/
and instead foo.dll and foo.o are generated. What might be the problem?

Related

The installation of the development version of `dplyr` is not working : "Error: ! System command 'Rcmd.exe' failed"

Code
devtools::install_github("tidyverse/dplyr")
Error message
Downloading GitHub repo tidyverse/dplyr#HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: tidyselect (190f80d87... -> 87b91186d...) [GitHub]
5: vctrs (0.4.1 -> 7c9d973b3...) [GitHub]
6: lifecycle (1.0.1 -> a2666fc50...) [GitHub]
7: cli (3.3.0 -> 3.4.0 ) [CRAN]
Enter one or more numbers, or an empty line to skip updates:
✔ checking for file 'C:\Users\julie\AppData\Local\Temp\Rtmp6lTT4z\remotes399069323c46\tidyverse-dplyr-5f967b4/DESCRIPTION' ...
─ preparing 'dplyr': (591ms)
✔ checking DESCRIPTION meta-information ...
─ cleaning src
─ installing the package to process help pages
-----------------------------------
─ installing *source* package 'dplyr' ...
** using staged installation
** libs
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c chop.cpp -o chop.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c filter.cpp -o filter.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c funs.cpp -o funs.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c group_by.cpp -o group_by.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c group_data.cpp -o group_data.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c imports.cpp -o imports.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c init.cpp -o init.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c mask.cpp -o mask.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c mutate.cpp -o mutate.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c slice.cpp -o slice.o
g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-42~1.1/include" -DNDEBUG -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -Wall -pedantic -fdiagnostics-color=always -c summarise.cpp -o summarise.o
g++ -std=gnu++11 -shared -s -static-libgcc -o dplyr.dll tmp.def chop.o filter.o funs.o group_by.o group_data.o imports.o init.o mask.o mutate.o slice.o summarise.o -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-42~1.1/bin/x64 -lR
installing to C:/Users/julie/AppData/Local/Temp/Rtmp0ADJEi/Rinst523c256932ce/00LOCK-dplyr/00new/dplyr/libs/x64
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'vctrs' 0.4.1 is being loaded, but >= 0.4.1.9000 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'dplyr'
─ removing 'C:/Users/julie/AppData/Local/Temp/Rtmp0ADJEi/Rinst523c256932ce/dplyr'
-----------------------------------
ERROR: package installation failed
Error: Failed to install 'dplyr' from GitHub:
! System command 'Rcmd.exe' failed
It seems to be a problem with the vctrs package, but reinstalling this package did not change anything. Do I have to install the development version of vctrs?
Note that after the line Enter one or more numbers, or an empty line to skip updates:, it proceeds without waiting for my input
EDIT : after installing packages recommended in the message above, I get the following error message
Error: Failed to install 'dplyr' from GitHub:
HTTP error 403.
API rate limit exceeded for 37.65.12.149. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Rate limit remaining: 0/60
Rate limit reset at: 2022-09-10 14:29:33 UTC
To increase your GitHub API rate limit
- Use `usethis::create_github_token()` to create a Personal Access Token.
- Use `usethis::edit_r_environ()` and add the token as `GITHUB_PAT`.

Problem with installation of vegan package - cannot find -lgfortran

I was installing another package called vcfR where it says vegan is source package and needs to be installed, then it showed errors when installing. So I decided to install vegan package first.
This is an online R studio, the package I need to analyse is too big to be done on my laptop. The online R studio is by my school server, which was in-built in a ssh server account.
below is the error message:
Installing package into ‘/home/joyzheng/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/vegan_2.5-7.tar.gz'
Content type 'application/x-gzip' length 2074611 bytes (2.0 MB)
==================================================
downloaded 2.0 MB
* installing *source* package ‘vegan’ ...
** package ‘vegan’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c data2hill.c -o data2hill.o
gfortran -fpic -g -O2 -c decorana.f -o decorana.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c getF.c -o getF.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c goffactor.c -o goffactor.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c init.c -o init.o
gfortran -fpic -g -O2 -c monoMDS.f -o monoMDS.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c nestedness.c -o nestedness.o
gfortran -fpic -g -O2 -c ordering.f -o ordering.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c pnpoly.c -o pnpoly.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c stepacross.c -o stepacross.o
gcc -std=gnu99 -I"/opt/R/4.0.3/lib/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c vegdist.c -o vegdist.o
gcc -std=gnu99 -shared -L/opt/R/4.0.3/lib/R/lib -L/usr/local/lib -o vegan.so data2hill.o decorana.o getF.o goffactor.o init.o monoMDS.o nestedness.o ordering.o pnpoly.o stepacross.o vegdist.o -L/opt/R/4.0.3/lib/R/lib -lRlapack -L/opt/R/4.0.3/lib/R/lib -lRblas -lgfortran -lm -lquadmath -lgfortran -lm -lquadmath -L/opt/R/4.0.3/lib/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [vegan.so] Error 1
ERROR: compilation failed for package ‘vegan’
* removing ‘/home/joyzheng/R/x86_64-pc-linux-gnu-library/4.0/vegan’
Warning in install.packages :
installation of package ‘vegan’ had non-zero exit status```

RcppArmadillo: failing to install on Ubuntu16.04

I am trying to install Rcpp on Ubuntu. Here are some environment details:
R version:3.4.0
g++ --version: Ubuntu 5.4.0-6ubuntu1~16.04.4
If I have a blank Makevars file, RcppArmadillo can be installed but with some warnings about OpenMp
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from RcppArmadillo.cpp:22:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from RcppExports.cpp:4:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fastLm.cpp -o fastLm.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from fastLm.cpp:22:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/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 (RcppArmadillo)
After I added PKG_CXXFLAGS=-std=c++11 to Makevars, I got a error message as following:
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -std=c++11 -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
RcppArmadillo.cpp:22:27: fatal error: RcppArmadillo.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:168: recipe for target 'RcppArmadillo.o' failed
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo’
* restoring previous ‘/home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo’
Warning in install.packages :
installation of package ‘RcppArmadillo’ had non-zero exit status
The wield thing is that when I tried to re-install RcppArmadillo on my mac(10.11), the same problem occurred. Could anybody enlighten me?
This is 16.10 which I have here at hone, if you wish I can repeat it at work tomorrow with 16.04:
edd#bud:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
edd#bud:~$ Rscript -e 'install.packages("RcppArmadillo")'
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RcppArmadillo_0.7.960.1.1.tar.gz'
Content type 'application/x-gzip' length 1115539 bytes (1.1 MB)
==================================================
downloaded 1.1 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 ccache g++ accepts -g... yes
checking how to run the C++ preprocessor... ccache g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether ccache g++ accepts -g... (cached) yes
checking whether g++ version is sufficient... (6.2.0) yes
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... found
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloLapack.h
** libs
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppArmadillo.cpp -o RcppArmadillo.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppExports.cpp -o RcppExports.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c fastLm.cpp -o fastLm.o
ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/RcppArmadillo/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 (RcppArmadillo)
The downloaded source packages are in
‘/tmp/Rtmp2hQNrn/downloaded_packages’
edd#bud:~$
That I usee ccache is not material. This. Just. Works.

R install package Rcplex

I already follow INSTALL STEP at INSTALL
but something wrong happen when I install the package
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex.c -o Rcplex.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_QCP.c -o Rcplex_QCP.o
Rcplex_QCP.c: In function 'Rcplex_QCP':
Rcplex_QCP.c:37:7: warning: unused variable 'trace' [-Wunused-variable]
int trace = INTEGER(getListElement(control,"trace"))[0];
^
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_params.c -o Rcplex_params.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_utils.c -o Rcplex_utils.o
C:/Rtools/mingw_32/bin/../lib/gcc/i686-w64-mingw32/4.9.3/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lcplex1263
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'Rcplex'
When you go to the package documentation at: https://cran.r-project.org/web/packages/Rcplex/index.html ... You make no mention of satisfying the system requirements:
SystemRequirements: IBM ILOG CPLEX libraries and headers
The linker that gcc uses, ld, cannot find the shared library for CPLEX. According to the INSTALL document, you need to verify that CPLEX_LIB_PATH is defined to point to the path where the CPLEX dll's are located. From your output, I'd venture
set CPLEX_LIB_PATH="C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/lib"
is what you need.

Package install error: compilation failed

I recently updated R to 3.1.0. I tried to move my packages over to 3.1 inside the R.Framework (I'm running OSX Mavericks) and somehow made a mess of it, so did a complete uninstall of everything before a clean install.
When reinstalling packages I had no issues until I hit the forecast package which yields the following error:
package ‘forecast’ is available as a source package but not as a binary
Warning in install.packages :
package ‘forecast’ is not available (for R version 3.1.0)
I actually had R 3.1.0 and both forecast and hts working together prior to the reinstall so I suspect the problem stems from something I've done, rather than a compatibility problem.
I ran the following to see if I could unearth some more details about the install fail: install.packages("forecast", type = "source", verbose = T, quiet = F)
The output of which is a little beyond me, but may be of help in diagnosis:
system (cmd0): /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL
trying URL 'http://cran.rstudio.com/src/contrib/forecast_5.3.tar.gz'
Content type 'application/x-gzip' length 150395 bytes (146 Kb)
opened URL
==================================================
downloaded 146 Kb
foundpkgs: forecast, /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
files: /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
* installing *source* package ‘forecast’ ...
** package ‘forecast’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c calcBATS.cpp -o calcBATS.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c calcTBATS.cpp -o calcTBATS.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etsTargetFunction.cpp -o etsTargetFunction.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etsTargetFunctionWrapper.cpp -o etsTargetFunctionWrapper.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etscalc.c -o etscalc.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etspolyroot.c -o etspolyroot.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c makeBATSMatrices.cpp -o makeBATSMatrices.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c makeTBATSMatrices.cpp -o makeTBATSMatrices.o
makeTBATSMatrices.cpp:11:6: warning: unused variable 'lengthSeasonal' [-Wunused-variable]
int lengthSeasonal = 0;
^
1 warning generated.
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c updateMatrices.cpp -o updateMatrices.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c updateTBATSMatrices.cpp -o updateTBATSMatrices.o
updateTBATSMatrices.cpp:38:10: warning: unused variable 'gammaVector' [-Wunused-variable]
double *gammaVector;
^
1 warning generated.
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o forecast.so calcBATS.o calcTBATS.o etsTargetFunction.o etsTargetFunctionWrapper.o etscalc.o etspolyroot.o makeBATSMatrices.o makeTBATSMatrices.o updateMatrices.o updateTBATSMatrices.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [forecast.so] Error 1
ERROR: compilation failed for package ‘forecast’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/forecast’
Warning in install.packages :
installation of package ‘forecast’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T/RtmpzTzSpG/downloaded_packages’
I'd really appreciate some help here. Much of the code I've been working on lately relies on functions in forecast.
Here is what I did (RcppArmadillo Compile Errors on OS X Mavericks)
Install gfortran from brew (if you don't have brew, Google it. Installation is straightforward):
brew install gfortran
If it's installed, upgrade to latest with:
brew upgrade gfortran
Then do one of the following:
ln -s /usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.* /usr/local/lib/
or add this line to the ~/.R/Makevars file:
FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran
I did the second option.
Now run install.packages("forecast", type = "source") again and it should work.
In my case, I was trying to install the latest version of {forecast} package with devtools::install_github("robjhyndman/forecast") and had the similar error.
Then, although I am not sure if what I did is right, following mchangun's answer I did as follows and the error was resolved:
brew upgrade gcc
Error: gcc 5.2.0 already installed
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
ls /usr/local/Cellar/gcc
4.9.2 4.9.2_1 5.2.0
Add the line FLIBS=-L/usr/local/Cellar/gcc/5.2.0 to the ~/.R/Makevars file
Run devtools::install_github("robjhyndman/forecast") and it worked.
Terminal
brew install gcc
gcc --version
ls /usr/local/Cellar/gcc
6.3.0_1
sudo vi /Library/Frameworks/R.framework/Resources/etc/Makeconf
Add the line FLIBS=-L/usr/local/Cellar/gcc/6.3.0_1
Rstudio:
install.packages("forecast"
Download gfortran from https://gcc.gnu.org/wiki/GFortranBinariesMacOS
sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran
Then install gfortran
sudo vi /Library/Frameworks/R.framework/Resources/etc/Makeconf
change all gfortran-4.8 to gfortran
FC = gfortran
FCFLAGS = -Wall -g -O2 $(LTO)
FCLIBS =
F77 = gfortran
F77_VISIBILITY =
FFLAGS = -g -O2 $(LTO)
FLIBS = -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm
change above FLIBS to the below
FLIBS = -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
To install gfortran, use
brew cask install gfortran

Resources