I'm trying to install reticulate so I can execute some Python code I've written from within R. Unfortunately, I'm having trouble installing the package and haven't had much luck in determining the reason.
I've found that it likely has something to do with compiling the package and possible issues with gcc or different versions of c++ compilers, but I'm a bit out of my depth with those issues and haven't been able to get anything working. I've tried uninstalling and reinstalling xcode command line tools, but that didn't solve the issue. Beyond that, I'm not entirely sure where to start. I'm hoping somebody has experienced this and there's a straightforward answer, I'd really appreciate any help.
> install.packages('reticulate')
There is a binary version available but the source version is later:
binary source needs_compilation
reticulate 1.13 1.14 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘reticulate’
trying URL 'https://cran.rstudio.com/src/contrib/reticulate_1.14.tar.gz'
Content type 'application/x-gzip' length 1504849 bytes (1.4 MB)
==================================================
downloaded 1.4 MB
* installing *source* package ‘reticulate’ ...
** package ‘reticulate’ successfully unpacked and MD5 sums checked
** libs
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c event_loop.cpp -o event_loop.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c libpython.cpp -o libpython.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c output.cpp -o output.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c python.cpp -o python.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c readline.cpp -o readline.o
/usr/local/bin/gcc-8 -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 reticulate.so RcppExports.o event_loop.o libpython.o output.o python.o readline.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/reticulate/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘reticulate’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/reticulate/libs/reticulate.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/reticulate/libs/reticulate.so, 6): Symbol not found: __ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/reticulate/libs/reticulate.so
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/3.5/Resources/library/reticulate/libs/reticulate.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/reticulate’
Warning in install.packages :
installation of package ‘reticulate’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/4g/ctbqp07114x4brzp4hr8zfc40000gn/T/RtmpDNvElq/downloaded_packages’
Session Info:
> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.15.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.3 tools_3.5.3 yaml_2.2.0
Okay, I suggest to use conda to create a new environment and install there R anew. Because then you solve the issues - since only one line conda install -c conda-forge r-reticulate will install you reticulate and r-base solving for you all issues.
However some people (who don't know what conda is) won't be happy with my suggestion. I can't and won't help them.
But for those who know conda, I recommend:
conda create --name R_reticulate
source activate R_reticulate
conda install -c conda-forge r-reticulate
(of course you could determine version numbers when installing into conda environment ...)
if the version of R in your local env now is the same like your global R, you can even overtake most of the library installed in the pre-existing R - thus you don't have to reinstall them all over again. Simply by manipulating the path variable in your conda env's R.
(Just as a hack and if you are lazy to install everything anew, probably because you want just to play around with reticulate first, before you install it into your global R).
For that, in your global R, determine where your R packages are installed by .libPaths() from within your global R console.
Then start R in your R_reticulate conda environment,
and at beginning of session do
my_libPaths <- .libPaths()
# and e.g. add one or some of your global .libPaths() paths
# to here by
my_libPaths <- c(my_libPaths, one_of_global_path)
.libPaths(my_libPaths) # assign new libpaths!
# the order of the paths in the vector is important - decides about where R looks first!
# of course you can change order like you want in the vector!
By that, you don't have to re-install libraries.
However, the version number of global and local (conda) R must be same so that this works.
Otherwise you will get always warnings when loading libraries ...
Simpler is of course to re-install everything into your conda env's R. (conda will help you for this a lot!).
Related
I apologize in advance if this question has been asked before but I haven't been able to find a suitable answer after days of searching.
I have a package that has a couple of small functions written in C++ using Rcpp (package can be found here). When trying to install this package on Linux systems (both local install and via Github Actions - Ubuntu 18.04, 20.04) the compiling procedure was successful but R cannot load the package because an .so file was not found. Mac and Windows systems work fine and there were no R CMD CHECK issues when tested on these systems.
I was wondering if there is any way to solve this issue? I was thinking of adding something in .Makevars but I don't know what to add.
Thank you so much in advance.
─ installing *source* package ‘CBEA’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/local/lib/R/include" -DNDEBUG -I'/__w/_temp/Library/Rcpp/include' -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -pedantic -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/local/lib/R/include" -DNDEBUG -I'/__w/_temp/Library/Rcpp/include' -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -pedantic -c gmeans.cpp -o gmeans.o
g++ -std=gnu++11 -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o CBEA.so RcppExports.o gmeans.o -L/usr/local/lib/R/lib -lR
installing to /tmp/RtmpwFufM0/Rinst8982598ffd0c/00LOCK-CBEA/00new/CBEA/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘CBEA’ in library.dynam(lib, package, package.lib):
shared object ‘cbea.so’ not found
Error: loading failed
Execution halted
ERROR: loading failed
─ removing ‘/tmp/RtmpwFufM0/Rinst8982598ffd0c/CBEA’
Your (generated) NAMESPACE file has two entries referring to the package:
useDynLib(CBEA, .registration = TRUE)
useDynLib(cbea, .registration = TRUE)
Remove the second one (i.e. remove whereever you tell roxygen2 to add it, and you will be fine. The rror message you see and quote indicates a case issue as on Linux, cbea.so is different from CBEA.so (whereas macOS and Windows let you get away with it).
Installing a package from source fails for me on my windows machine. I uninstalled RStudio, R and deleted rtools40 folder, restarted and reinstalled those items. I believe I have the path set up appropriately.
Here's the code I tried, using some troubleshooting help from here:
#troubleshooting installation
pkgbuild::find_rtools()
pkgbuild::has_rtools(TRUE)
pkgbuild::check_rtools(TRUE)
pkgbuild::rtools_path()
pkgbuild::check_build_tools(TRUE)
pkgbuild::check_compiler(TRUE)
Sys.getenv("PATH")
Sys.getenv('BINPREF')
sessionInfo()
#Test installation from source via CRAN
pkgbuild::with_build_tools(install.packages("lme4", type = "source"))
And here is the output:
Restarting R session...
> #troubleshooting installation
> pkgbuild::find_rtools()
[1] TRUE
> pkgbuild::has_rtools(TRUE)
[1] TRUE
> pkgbuild::check_rtools(TRUE)
[1] TRUE
> pkgbuild::rtools_path()
[1] "C:\\rtools40/usr/bin"
> pkgbuild::check_build_tools(TRUE)
Your system is ready to build packages!
> pkgbuild::check_compiler(TRUE)
Trying to compile a simple C file
Running "C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe" SHLIB foo.c
Warning message:
In system(cmd) : 'make' not found
Error: Failed to compile C code
> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-4.0.3\\bin\\x64;C:\\rtools40\\bin;C:\\rtools40\\mingw64\\bin;C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\wbin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Pandoc\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Users\\nealm\\AppData\\Local\\Microsoft\\WindowsApps;C:\\ProgramData\\Anaconda3;C:\\ProgramData\\Anaconda3\\Scripts;C:\\Users\\nealm\\.conda\\pkgs\\conda-4.7.5-py37_0\\Scripts;C:\\ProgramData\\Anaconda3\\Library\\bin;C:\\Users\\nealm\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\nealm\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\nealm\\AppData\\Roaming\\TinyTeX\\bin\\win32;"
> Sys.getenv('BINPREF')
[1] "C:/rtools40/mingw64/bin/"
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] processx_3.4.5 compiler_4.0.3 assertthat_0.2.1 R6_2.5.0 cli_2.2.0 livecode_0.1.0.9000
[7] prettyunits_1.1.1 tools_4.0.3 glue_1.4.2 rstudioapi_0.13 Rcpp_1.0.5 remotes_2.2.0
[13] crayon_1.3.4 fansi_0.4.1 callr_3.5.1 ps_1.4.0 pkgbuild_1.1.0
>
> #Test installation from source via CRAN
> pkgbuild::with_build_tools(install.packages("lme4", type = "source"))
Installing package into ‘C:/Rpackages’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/lme4_1.1-26.tar.gz'
Content type 'application/x-gzip' length 3297635 bytes (3.1 MB)
downloaded 3.1 MB
* installing *source* package 'lme4' ...
** package 'lme4' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c external.cpp -o external.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c glmFamily.cpp -o glmFamily.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c optimizer.cpp -o optimizer.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c predModule.cpp -o predModule.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c respModule.cpp -o respModule.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o lme4.dll tmp.def external.o glmFamily.o optimizer.o predModule.o respModule.o -LC:/PROGRA~1/R/R-40~1.3/bin/i386 -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/R/R-40~1.3/bin/i386/R.dll when searching for -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/R/R-40~1.3/bin/i386/R.dll when searching for -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lR
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'lme4'
* removing 'C:/Rpackages/lme4'
* restoring previous 'C:/Rpackages/lme4'
Warning in install.packages :
installation of package ‘lme4’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\nealm\AppData\Local\Temp\RtmpwPwykm\downloaded_packages’
>
The problem does not appear to be specific to the lme4 package.
This is more of a work around than a proper answer. The alternative to installing and building from source is to install a pre-built binary. If one is not available, you can build it remotely.
In this case, for the package of interest for me, rundel/livecode on github, I:
Forked the repo (in this case rundel/livecode). This step might be optional.
Downloaded the tar.gz (remotes::install_github("markbneal/livecode") which doesn't install it, but the error tells you where it saves the .tar.gz file locally.
Used rhub to build the package binary for windows, go to this website https://builder.r-hub.io/ and upload your tar.gz file, ensuring rhub has your email address (click "advanced" button to provide your email address as alternate - you will need to validate it). That emails me a zip 5 minutes later.
Then copy the livecode folder in the zip that is emailed to me to my "R packages" folder location.
Package should now work for you, in my case library(livecode)
Edited six months later when I had to use this process again!
Working on a small Rcpp package to use Boost and some of its geometry functions in C.
Finished writing the functions and everything was working well. Tested that everything was working properly (Clean and Rebuild and testing the functions) one last time before pushing up to GitHub. Once I double-checked the directory was all cleanly stored in GitHub I removed the directory from my local machine. It should also be noted that I have Roxygen2 running on this and managing the NAMESPACE file.
Upon cloning the directory back and Clean and Rebuild I get the following error:
==> Rcpp::compileAttributes()
* Updated R/RcppExports.R
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source MinimumRcpp
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library’
* installing *source* package ‘MinimumRcpp’ ...
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c findParetoSet.cpp -o findParetoSet.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c kintersection.cpp -o kintersection.o
clang++ -std=gnu++11 -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 MinimumRcpp.so RcppExports.o findParetoSet.o kintersection.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/MinimumRcpp/libs
** R
** byte-compile and prepare package for lazy loading
Error in asNamespace(ns) : not a namespace
Error : unable to load R code in package ‘MinimumRcpp’
ERROR: lazy loading failed for package ‘MinimumRcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/MinimumRcpp’
Exited with status 1.
Of course, nothing changed in the code. However, I do have the following .gitignore files:
# /.gitignore
inst/lib
.Rproj.user ## Could this be an issue?
.Rproj.user/ ## Could this be an issue?
.Rproj.user/** ## Could this be an issue?
src/*.o
src/*.so
src/*.dll
src/symbols.rds
.Rhistory
.RData
.DS_Store
## QtCreator
Rcpp.pro
Rcpp.pro.user
*.autosave
.#*
*.tar.gz
vignettes/*_cache
## GNU global
GPATH
GRTAGS
GTAGS
##
local/
## docker helpers
docker/*sh
docker/*/*.sh
# /.Rbuildignore
debian
inst/doc/html
inst/doc/latex
inst/doc/man
inst/doc/jss.bst
vignettes/jss.bst
^.*\.Rproj$
^\.Rproj\.user$
vignettes/notyet
doxyfile
\.travis\.yml
\.dir-locals\.el
\.clang_format
vignettes/getCurrentVersionsOfCitedPackages.R
^Contributing.md$
^\.codecov\.yml$
inst/include/Rcpp.h.new
inst/include/Rcpp.h.old
LICENSE
.*\.tar\.gz$
\.editorconfig
docker
^GPATH
^GRTAGS
^GTAGS
^local
vignettes/Makefile
vignettes/rmd
\.github
Is it possible that some package data that was necessary for building the package was left behind and is causing the current issues?
Any assistance would be appreciated. Additionally, any advice on how to debug this would help as the current output messages are quite nebulous and are leaving me directionless.
Here is the GitHub repo for reproducibility: https://github.com/eduardoRubioG/MinimumRcpp
Rookie mistake, but a serious one:
never ever keep script files in your R/ directory
everything (and we mean everything) in the directory gets sourced (provided it looks like R code, _i.e. end in .R)
you left a script with a library(MinimumRcpp) call in there so now your package byte-code compilation wants to source itself --> not a good plan
in short, keep such scripts but put them in e.g. local/ and exclude local/ via .Rbuildignore.
Plus an important style lesson
do not leave rm(list = ls(all = TRUE)) in your code
So if you do mv R/script.R R/script.R.txt and rebuild, all is good.
(I get a half-dozen warnings because n is not a size_t but compared to one. You may want to cast it earlier.)
I tried to install RcppEigen on amazon EC2 (on a t1.micro to
make sure It works) & ubuntu 13.04. I tried with both R version was 2.15.2 and 3.0, 32bit ubuntu and 64bit ubuntu. Any time I got the following:
root#ip-10-224-4-239:/home/ubuntu# R CMD INSTALL RcppEigen_0.3.1.2.1.tar.gz
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -O2 -pipe -g -c RcppEigen.cpp -o RcppEigen.o
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -O2 -pipe -g -c fastLm.cpp -o fastLm.o
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
make: *** [fastLm.o] Error 4
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/usr/local/lib/R/site-library/RcppEigen’
Anyone has an idea on how to get RcppEigen to run on EC2?
(Rcpp installs flawlessly....)
That looks like a "simple" out of memory issue.
C++ can be demanding as is, and complex template code (which Eigen surely is) demands even more resources. Simply try allocating more memory -- otherwise it is hard to kill g++.
I am trying to install the package called topicmodels in R and I have not had success. Here's what I have tried...
Action:
Install the package using install.packages("topicmodels")
Result:
package ‘topicmodels’ is available as a source package but not as a binary
Warning in install.packages :
package ‘topicmodels’ is not available (for R version 3.1.0)
So there I said okay let's install from source
Action:
install.packages("/Users/my_name/Downloads/topicmodels_0.2-1.tar.gz",repos=NULL,type="source")
Result:
* installing *source* package ‘topicmodels’ ...
** package ‘topicmodels’ 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 -fPIC -Wall -mtune=core2 -g -O2 -c cokus.c -o cokus.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c common.c -o common.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c ctm.c -o ctm.o
ctm.c:29:10: fatal error: 'gsl/gsl_rng.h' file not found
include gsl/gsl_rng.h
1 error generated.
make: *** [ctm.o] Error 1
ERROR: compilation failed for package ‘topicmodels’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/topicmodels’
Warning in install.packages :
installation of package ‘/Users/me/Downloads/topicmodels_0.2-1.tar.gz’ had non-zero exit status
So then I researched this gsl thing and came upon this link. And for the moment I thought all of my problems were gone and when I finally follow these directions. I get the following error (in the terminal)...
Warning in untar2(tarfile, files, list, exdir, restore_times) :
using pax extended headers
ERROR: cannot extract package from ‘topicmodels.tar.gz’
First of all you have to install gsl. Once you have that installed you can try to install the R package. You can download gsl from here (there you can pick the latest version gsl-latest.tar.gz). Once it's been downloaded, install it by doing the following:
Decompress the downloaded file (in my case the "latest" file contained this version: gsl-1.16)
Open the "Terminal"
Then (using the Terminal), move inside the folder that you created on step 1. In my case I had the file on the folder called "Downloads", so I moved to the newly created folder by doing:
cd Downloads/gsl-1.16
Once you are within that folder run the following commands (in order):
./configure
make
sudo make install
After doing it you won't get the previous error saying fatal error: 'gsl/gsl_rng.h' file not found, so you can try again the installation.
Now go back to your R environment (e.g., RStudio) to try again to install the package by doing:
install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
I had the same problem, and after doing this I got the R package correctly installed, I hope it also works in your case.
If you already using homebrew. It is better and faster to fix with variables than installing gsl manually from source.
Install gsl with homebrew brew install gsl
Edit ~/.R/Makevars and add.
PKG_LIBS=-L/usr/local/opt/gettext/lib
CFLAGS=-I/usr/local/opt/gsl/include
LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas
If you are using Linux based on Debian, that's my solution:
Using terminal run sudo apt install gsl-bin libgsl-dbg libgsl-dev libgsl25 libgslcblas0;
Then, using R console, run install.packages("topicmodels",dependencies =T);
Enjoy!!