Package Passes R CMD check in Linux, Windows Binary Fails - r

I submitted version 0.1-8 of a robust package I created to CRAN. R CMD Check passed on my computer runnning 64 bit Ubuntu and Rstudio. The Linux and Mac binaries are passing on CRAN. The windows binaries are failing on CRAN. The only difference between version 0.1-7 and 0.1-8 is I changed the namespace to adhere to the new version of R and I improved the documentation. None of the code has been changed.
https://cran.r-project.org/web/packages/robustreg/index.html
https://cran.r-project.org/web/checks/check_results_robustreg.html
Can anyone help me with the below error message?
* using log directory 'd:/Rcompile/CRANpkg/local/3.2/robustreg.Rcheck'
* using R version 3.2.1 (2015-06-18)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'robustreg/DESCRIPTION' ... OK
* this is package 'robustreg' version '0.1-8'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking whether package 'robustreg' can be installed ... ERROR
Installation failed.
See 'd:/Rcompile/CRANpkg/local/3.2/robustreg.Rcheck/00install.out' for details.
* DONE
The installation logfile:
* installing *source* package 'robustreg' ...
** package 'robustreg' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
make[1]: Entering directory `/cygdrive/d/temp/RtmpI9QsDz/R.INSTALL4b704d36335d/robustreg/src-i386'
g++ -I"D:/RCompile/recent/R-3.2.1/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/CRANpkg/lib/3.2/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include" -O3 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
g++ -I"D:/RCompile/recent/R-3.2.1/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/CRANpkg/lib/3.2/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include" -O3 -Wall -mtune=core2 -c fit.cpp -o fit.o
g++ -shared -s -static-libgcc -o robustreg.dll tmp.def RcppExports.o fit.o -Ld:/RCompile/r-compiling/local/local320/lib/i386 -Ld:/RCompile/r-compiling/local/local320/lib -LD:/RCompile/recent/R-3.2.1/bin/i386 -lR
fit.o:fit.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper<false>::apply<arma::Mat<double>, arma::Col<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Col<double>, arma::glue_times> const&)]+0x262): undefined reference to `dgemv_'
fit.o:fit.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper<false>::apply<arma::Mat<double>, arma::Col<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Col<double>, arma::glue_times> const&)]+0x4a2): undefined reference to `dgemv_'
fit.o:fit.cpp:(.text$_ZN4arma27glue_times_redirect2_helperILb0EE5applyINS_3MatIdEENS_3ColIdEEEEvRNS3_INT_9elem_typeEEERKNS_4GlueIS7_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper<false>::apply<arma::Mat<double>, arma::Col<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Col<double>, arma::glue_times> const&)]+0xb4c): undefined reference to `dgemv_'
collect2: ld returned 1 exit status
make[1]: Leaving directory `/cygdrive/d/temp/RtmpI9QsDz/R.INSTALL4b704d36335d/robustreg/src-i386'
make[1]: Entering directory `/cygdrive/d/temp/RtmpI9QsDz/R.INSTALL4b704d36335d/robustreg/src-i386'
make[1]: Leaving directory `/cygdrive/d/temp/RtmpI9QsDz/R.INSTALL4b704d36335d/robustreg/src-i386'
no DLL was created
ERROR: compilation failed for package 'robustreg'
* removing 'd:/Rcompile/CRANpkg/lib/3.2/robustreg'
* restoring previous 'd:/Rcompile/CRANpkg/lib/3.2/robustreg'

According to its automatically-created GitHub mirror and the src/ directory there in, you do not have a file src/Makevars.win. And you now have a linking error with LAPACK routines.
Simply add a file such as this one added when you use RcppArmadillo.package.skeleton() containing just
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
and you should be all set:
I am surprised this worked previously. You mostly got lucky--our documentation clearly says you need it.

Related

R package source install, no compiler

I am trying to install some packages from source on a linux (RHEL) server. But whenever the package requires some C++ compilation it fails.
For example, I try to install Ckmeans.1d.dp package. If I call R CMD INSTALL Ckmeans.1.dp_4.2.1.tar.gz I get the following output (truncated) where you can see the compiler is omitted.
...* installing *source* package ‘Ckmeans.1d.dp’ ...
** libs
I/usr/include/R -DNDEBUG -I/usr/local/include -c Ckmeans.1d.dp.cpp -o Ckmeans.1d.dp.o
make: I/usr/include/R: Command not found
...
-shared -L/usr/local/lib64 -o Ckmeans.1d.dp.so Ckmeans.1d.dp.o Ckmeans.1d.dp_main.o dynamic_prog.o fill_SMAWK.o fill_log_linear.o fill_quadratic.o select_levels.o weighted_select_levels.o -L/usr/lib64/R/lib -lR
/bin/sh: line 2: -shared: command not found
make: *** [Ckmeans.1d.dp.so] Error 127
ERROR: compilation failed for package ‘Ckmeans.1d.dp’
I am currently stuck with a server that only has R 3.1.1 and I do not have admin privileges. The $Rhome/etc/Makeconf has CXX and CC defined. I have also verified g++ and gcc are installed.
What could be happening here?
Invariably an environment variable with an 'empty' value gets expanded. Maybe (just guessing here) the package would use C++11, so $(CXX11} -shared gets expanded and ... becomes -shared and an error is triggered.
Look at the R settings, eg via less $(R HOME)/etc/Makevars and see what it expects.
I think you can get by, if you must, installing gcc et al below, say, ~/bin. Some packages will require a compiler...

R package DESCRIPTION - Remotes from Bioconductor should install binary

I am working on an R package (https://github.com/bgbrink/dropClust) and I was testing if it can be installed, since it depends on a number of packages both from CRAN and from Bioconductor. I specified the three dependencies from Bioconductor in the DESCRIPTION:
Remotes:
bioc::flowDensity,
bioc::SamSPECTRAL,
bioc::flowPeaks
However, when I try to install the package, the installation of flowPeaks fails, because the script downloades the source version of the package, which requires GSL to be present in order to be compiled.
* installing *source* package ‘flowPeaks’ ...
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include `gsl-config --cflags` -fPIC -Wall -g -O2 -c Rpack.cpp -o Rpack.o
/bin/sh: gsl-config: command not found
In file included from Rpack.cpp:16:
./gvector_gmatrix.h:24:10: fatal error: 'gsl/gsl_math.h' file not found
#include <gsl/gsl_math.h>
^
1 error generated.
make: *** [Rpack.o] Error 1
ERROR: compilation failed for package ‘flowPeaks’
When I download the package manually from Bioconductor, everything works fine, because the script downloades the binary version of the package. Can I specify somewhere that this is the default behaviour? I tried options(pkgType = "binary") without success.
Edit: No new ideas, so I'm bumping it once.

Tell Rstudio to use mpif90 instead of gfortran

In order to learn how to create a R packages that uses Fortran I created a simple one to calculate Pi with a monte carlo simulation. Now I'm trying to make the Fortran code parallel with MPI.
When I add use MPI to my fortran code and click the Build and Reload buton on Rstudio I get the following error.
==> R CMD INSTALL --no-multiarch --with-keep.source MyPi
* installing to library ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2’
* installing *source* package ‘MyPi’ ...
gfortran -fpic -g -O2 -fstack-protector-strong -c Fpi.f90 -o Fpi.o
/usr/lib/R/etc/Makeconf:161: recipe for target 'Fpi.o' failed
** libs
Fpi.f90:2.4:
use mpi
1
Fatal Error: Can't open module file 'mpi.mod' for reading at (1): No such file or directory
make: *** [Fpi.o] Error 1
ERROR: compilation failed for package ‘MyPi’
* removing ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
* restoring previous ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
Exited with status 1.
I think the problem is that Rstudio is trying to compile using gfortran instead of mpi90. I'm able to follow this post to do a very basic hello world, but there you compile the code with mpif90 -fpic -shared -o test.so test.f90
How can I tell Rstudio to use mpif90 -fpic -shared instead of gfortran?
I added this to src/Makevars
FC=mpif90
This is what I get:
==> R CMD INSTALL --no-multiarch --with-keep.source MyPi
* installing to library ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2’
* installing *source* package ‘MyPi’ ...
gfortran -fpic -g -O2 -fstack-protector-strong -c Fpi.f90 -o Fpi.o
/usr/lib/R/etc/Makeconf:161: recipe for target 'Fpi.o' failed
** libs
Fpi.f90:2.4:
USE MPI
1
Fatal Error: Can't open module file 'mpi.mod' for reading at (1): No such file or directory
make: *** [Fpi.o] Error 1
ERROR: compilation failed for package ‘MyPi’
* removing ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
* restoring previous ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
Exited with status 1.
You just need to set the FC flag in your Makevars file to indicate the fortran compiler you wish to use.
FC=mpif90
EDIT - The above doesn't work if included locally in your package
The FC macro will be overwritten when specified within a package Makevars because the src/Makevars file is read before $RHOME/etc/Makeconf which overwrites the FC macro. In order to change the default compiler is to create a Makevars file in a .R/ directory in your $HOME directory.
Then just create the file with the same line as above. Restart R and try to compile again (this worked on my Ubuntu system).

install RMySQL on windows

I am trying to install the package RMYSQL on windows.
To do so i followed this tutorial : http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/
But i am getting an error when i execute
install.packages(“RMySQL”, type = “source”)
In deed R returns me the following :
Installing package into ‘D:/Users/quentin/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb) opened URL
downloaded 161 Kb
* installing *source* package 'RMySQL' ...
** package 'RMySQL' correctement décompressé et sommes MD5 vérifiées
checking for $MYSQL_HOME... C:/Program Files (x86)/MySQL/mysql-5.6.19-win32
cygwin warning:
MS-DOS style path detected: C:/Program
Preferred POSIX equivalent is: /cygdrive/c/Program
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
test: Files: unknown operand
** libs
Avis : this package has a non-empty 'configure.win' file,
so building only the main architecture
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m64 -I"C:/PROGRA~1/R/R-31~1.0/include" -DNDEBUG -I"C:/Program Files (x86)/MySQL/mysql-5.6.19-win32"/include - I"d:/RCompile/CRANpkg/extralibs64/local/include"
-O2 -Wall -std=gnu99 -mtune=core2 -c
RS-DBI.c -o RS-DBI.o
RS-DBI.c: In function 'RS_na_set':
RS-DBI.c:1219:11: warning: variable 'c' set but not used [-Wunused-but-set-variable]
gcc -m64 -I"C:/PROGRA~1/R/R-31~1.0/include" -DNDEBUG -I"C:/Program Files (x86)/MySQL/mysql-5.6.19-win32"/include - I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall - std=gnu99 -mtune=core2 -c RS-MySQL.c -o RS-MySQL.o
RS-MySQL.c: In function 'RS_MySQL_fetch':
RS-MySQL.c:657:13: warning: variable 'fld_nullOk' set but not used [-Wunused-but-set- variable]
RS-MySQL.c: In function 'RS_DBI_invokeBeginGroup':
RS-MySQL.c:1137:30: warning: variable 'val' set but not used [-Wunused-but-set-variable]
RS-MySQL.c: In function 'RS_DBI_invokeNewRecord':
RS-MySQL.c:1158:20: warning: variable 'val' set but not used [-Wunused-but-set- variable]
RS-MySQL.c: In function 'RS_MySQL_dbApply':
RS-MySQL.c:1219:38: warning: variable 'fld_nullOk' set but not used [-Wunused-but-set- variable]
gcc -m64 -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o C:/Program Files (x86)/MySQL/mysql-5.6.19-win32/bin/libmySQL.dll - Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-31~1.0/bin/x64 -lR
collect2: ld returned 5 exit status
aucune DLL n'a pas été créé
ERROR: compilation failed for package 'RMySQL'
* removing 'D:/Users/quentin/Documents/R/win-library/3.1/RMySQL'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" CMD INSTALL -l "D:\Users\quentin\Documents\R\win-library\3.1" D:\Users\quentin\AppData\Local\Temp\2\RtmpOwB1UH/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘D:\Users\quentin\AppData\Local\Temp\2\RtmpOwB1UH\downloaded_packages’
I couldn't manage to fix this problem so if someone have an idea.
i tried all the steps from all the instructions i could get, but still got the same problems as you got.
I finallly solved accidently by follow this code:
install.packages('RMySQL')
instead of
install.packages(“RMySQL”, type = “source”)
I cannot explain the reason, but it truly works.
I solved it by installing from a .zip file not from .tar.gz.
Make sure your MYSQL_HOME environment variable is set correctly and libmysql.dll is copied to bin folder!!!
Run install.packages('RMySQL') then when the "Do you want to install from sources..." window pops up select No.
Then copy the downloaded binary packages location from console.
Go to Packages -> Install, paste the location into Package archive and click Install.

error in R CMD build when editing c function in R package

I have modified a C function in the phmm package. Now I want to rebuild the package, but the following error occurred. How can I fix the error?
$ cd ~/Desktop/phmmw
$ R CMD build phmm
* checking for file ‘phmm/DESCRIPTION’ ... OK
* preparing ‘phmm’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to re-build vignettes
-----------------------------------
* installing *source* package ‘phmm’ ...
** libs
*** arch - x86_64
gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c arms.c -o arms.o
make: gcc-4.2: No such file or directory
make: *** [arms.o] Error 1
ERROR: compilation failed for package ‘phmm’
* removing ‘/private/var/folders/r0/9qv15p6j59j6jtfq775k6j380000gn/T/RtmpIPgvDE/Rinst48317ea7/phmm’
-----------------------------------
ERROR: package installation failed
Your R installation was configured with gcc in such a (suboptimal) was that the gcc-4.2 command was hardwired.
So you need to
either provide a command gcc-4.2, most commonly done via a symlink from gcc to gcc-4.2,
or change the R setting, presumably in the file $RHOME/etc/Makeconf where you need to look for CC
or change it on the fly by doing CC=gcc R CMD build phmm
You may need to modify more than just one CC setting, possibly CXX, LD and more. It may be as easy as always removing the -4.2 part.

Resources