To use dictionary learning and sparse coding methods, I am trying to install SPArse Modeling Software (spams) package in R. Their instruction says:
Download the .tar.gz file.
After Un-taring the file and entering the newly extracted folder, run the following command:
R CMD INSTALL --html -l \$R\_LIBS spams
In my case, I use
R CMD INSTALL --html -l /Library/Frameworks/R.framework/Resources/library spams
But I receive the following error messages:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__config:593:1: error:
templates must have C++ linkage
Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__config:594:20: error:
explicit specialization of non-template struct '__static_assert_test'
There are many other error messages which highlight some parts of the library codes (like the second error message) which seem to have the same root cause.
I am not sure if it helps but just in case, I am using Command Line Tools (OS X 10.11) Xcode 8 beta 6.
Confirmed. It's buggy code. Likely mixes C and C++ headers inside/outside of C "extern" blocks.
That uses to pass with older compilers. It does not more. You'll probably have to do some minor surgery on it -- helps if you know C(++) and R package structures.
So in short, it is not your use of R CMD INSTALL ... which is at fault here but rather the package you are trying to install. There is a reason we all prefer R software from CRAN as these issues have then been ironed out...
Related
First of all, sorry for my english and sorry for taking your time, I'm pretty sure the answers are online but it seems like I can't find the right keywords for this issue.
The problem: Python2 is installed but still asked as a dependency for every python2 module I want to install with my package manager.
I built python2 from source on Archlinux in a proot environment
(because I use termux on a non rooted phone and it's probably why yay did not worked as expected to install python2) and I think I did it well because "python2" open the python command line and "python2 -V" return me "Python 2.7.18", i can execute python scripts with it, etc.
I built python by downloading and uncompressing python2 from python.org, then in the uncompressed file ./configure --enable-optimization , make -s and make install.
I'm a noob so i don't know but i probably just need a way to handle python2 with pacman or a way to tell pacman that python2 is indeed installed.
repo.
I know to handle manualy built pkgs with pacman, but not software built from source. So i'v found a PKGBUILD for python2 but (again, probably because of the proot) when i use makepkg here what's happen :
[...
...
...]
==> Extracting sources...
-> Extracting Python-2.7.18.tar.xz with bsdtar
==> Starting prepare()...
bsdtar: Removing leading '/' from member names
patching file Makefile.pre.in
patch: setting attribute security.selinux for security.selinux: Permission denied
==> ERROR: A failure occurred in prepare().
Aborting...
So if anyone know how could i make makepkg works as intended or how could i tell pacman that python2 is already installed, it would totaly make my day.
PS : I know python2 is deprecated and as it's not updated anymore the security is getting worse and worse, but it's not for my main setup so don't worry. I also think i could install modules manually but it is not something i wish to do since i'd like to install the all BlackArch repo.
Trying to use rJava and have it use java version 11.
Currently it uses a previous installation I had of version 17.
When I run R CMD javareconf most of the settings look right.
Java interpreter : /Users/adam/.jenv/shims/java
Java version : 11.0.13
Java home path : /Library/Java/JavaVirtualMachines/zulu11.52.13-ca-jdk11.0.13-macosx_aarch64/zulu-11.jdk/Contents/Home
Java compiler : /Users/adam/.jenv/shims/javac
Java headers gen.: /Users/adam/.jenv/shims/javah
Java archive tool: /Users/adam/.jenv/shims/jar
...
and yet when I call rJava::.jcall("java.lang.System","S","getProperty","java.version") I still get version 17.
Consequently I've tried re-installing rJava from source. When I do this the installation recognizes Java 11 as the "default" java installation to use, but I run into a problem with my cpp compiler, as I see the error
ld: library not found for -lpcre2-8
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
when I run install.packages("rJava",type="source").
Other questions(1,2,3) have similar issues but my attempts to replicate the installation of the linker libraries, libpcre2-dev libbz2-dev zlib1g-dev as recommended to an ubuntu user did not work for me – I have not been able to find out how I might install the library as a Mac user . Furthermore, I'm not exactly sure if the "linkages" are setup appropriately in such cases.
Question
How/Where can I find and install the -lpcre2-8 package for the mac version specified below and ensure that the appropriate linkages are in place for the rJava compilation?
Details
I'm working on a Mac OS v12.0.1 (M1 chip), R v.4.1.2 using Rstudio v1.4.1717 to run R.
First, re-compiling won't have any effect. The Java version used on macOS is governed by:
the JAVA_HOME environment variable
system Java selection (see /usr/libexec/java_home)
Normally, JAVA_HOME is not set, so your macOS system setting is used. You can see your installed Java versions with /usr/libexec/java_home -V including which is selected:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
17, x86_64: "Java SE 17" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
1.8.0_252, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
If you want to change the default, you can set JAVA_HOME to the preferred value. For example:
## use Java 1.8
$ JAVA_HOME=`/usr/libexec/java_home -v 1.8` Rscript -e \
'print(rJava::J("java.lang.System")$getProperty("java.version"))'
[1] "1.8.0_252"
## use Java 17
$ JAVA_HOME=`/usr/libexec/java_home -v 17` Rscript -e \
'print(rJava::J("java.lang.System")$getProperty("java.version"))'
[1] "17"
Second, if you want to re-compile rJava, you will need all libraries used to build R. For CRAN R build those are provided in https://mac.r-project.org/bin/, but I would not recommend going there unless you want to modify rJava. You can make your life easier by not compiling JRI (embedding R in Java) support, i.e. adding --disable-jri since it's that part which requires the libraries used by R. Just the rJava package itself doesn't need it.
Finally, it's usually a lot faster to ask on the support page rJava Discussion.
After updating to macOS Big Sur 11.4 and installing the latest versions of R (4.1.0), RStudio (1.4.1717) and Xcode (12.5.1) (for Command Line Tools), I am unable to build and install my R package from source (which relies on complied C++ code) via devtools::build() and devtools::install().
Every time I do this in RStudio, I receive the error message:
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
When I call the above, I am prompted to select "Yes" to install the build tools. However, when I nothing happens.
I have checked to ensure Xcode CLT is installed, and sure enough, it is:
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
My package relies on both Rcpp and RcppArmadillo. I have installed these within RStudio. devtools is also installed.
I cannot even install my package directly from GitHub via devtools::install_github()
Any ideas on what could be going on here and how I can resolve the issue?
I followed the steps in this post:
clang-7: error: linker command failed with exit code 1 for macOS Big Sur
including altering the Makevars as per the above post.
If it helps, here is my old Makevars
## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here. It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Thanks!
A while back, I created a fork of the RDCOMClient package to keep it working with R 3.6 (https://github.com/dkyleward/RDCOMClient). People are now running into issues again because it won't work with R 4.0. The problem doesn't seem as easy to fix, and I'm hoping for some help.
If I flip Rstudio back to R 3.6 (and rtools35), I can use the package after installing with devtools::install_github(). When I try in R 4.0 (and rtools40), the package builds and I can connect over COM to an application. The first line of code below works, and xl is a COM pointer; however, trying to do anything with it (like set Excel to visible) will crash R.
xl <- RDCOMClient::COMCreate("Excel.Application")
xl[["Visible"]] <- TRUE
Again, the above works in R 3.6.
Is there is a way to continue building with the previous rtools? I came across https://github.com/r-windows/rtools-backports#readme, which talks about using rtools35 to keep building packages, so I have hope, but I don't understand how to make it happen.
Alternatively, if there are minor changes I can make to the R or cpp code that will solve my problem, I'm all ears. I'm a cpp novice, though.
This was a quick fix :
install.packages("RDCOMClient", repos = "http://www.omegahat.net/R")
Install R-4.0.0
Install Rtools35
Edit $R_HOME/etc/x64/Makeconf (for R-4.0.0-x64)
Rcmd INSTALL RDCOMClient
Rik's answer was incredibly helpful and got a version working; however, after spending a day on it, I was able to improve on it. I want to put that here in case I have to do it again. The main improvement is being able to build a working package for both 32- and 64-bit architectures. By default, R installs both, and this makes things easier when installing dependent packages.
The first two steps are the same:
Install R-4.0.0 (https://cran.r-project.org/bin/windows/base/old/4.0.0/R-4.0.0-win.exe)
Install Rtools35 (https://cran.r-project.org/bin/windows/Rtools/Rtools35.exe) in directory c:\Rtools
If (like me) you had already installed rtools40, a system environment variable named RTOOLS40_HOME is created. The first step is to change that to:
C:\rtools
If you don't have rtools40 installed, then create the RTOOLS40_HOME system environment variable.
Two changes are still needed in the make files. These are found in your R installation directory.
In etc\x64\Makeconf, add underscores to match the rtools35 directory structure by setting these values:
MINGW_PREFIX = /mingw_$(WIN)
BINPREF ?= "$(RTOOLS40_ROOT)/mingw_64/bin/"
Do the same in etc\i386\Makeconf:
MINGW_PREFIX = /mingw_$(WIN)
BINPREF ?= "$(RTOOLS40_ROOT)/mingw_32/bin/"
Do not set BINPREF as an environment variable, or this will overwrite the makefile changes (like RTOOLS40_HOME does). With these complete, finish off with the same steps that Rik outlined:
Open windows command prompt and change to the directory that contains the RDCOMClient subdirectory and type:
R CMD INSTALL RDCOMClient –-build RDCOMClient.zip
This installs RDCOMClient in the local installation of R-4.0.0 and additionally creates the file RDCOMClient_0.94-0.zip that can be installed on other systems using the following command:
install.packages("RDCOMClient_0.94-0.zip", repos = NULL, type = "win.binary")
I can confirm that the procedure delineated in the answer above leads in the right direction but a few extra steps may be required. I can also confirm that the procedure below produces a Windows binary file that can be installed and will run under R-4.0.0:
Install R-4.0.0 (https://cran.r-project.org/bin/windows/base/old/4.0.0/R-4.0.0-win.exe)
Install Rtools35 (https://cran.r-project.org/bin/windows/Rtools/Rtools35.exe) in directory c:\Rtools
Edit $R_HOME/etc/x64/Makeconf (for R-4.0.0-x64) by changing
## The rtools40 installer sets RTOOLS40_HOME, default to standard install path
RTOOLS40_HOME ?= c:/rtools40
to
## The rtools40 installer sets RTOOLS40_HOME, default to standard install path
RTOOLS40_HOME ?= c:/rtools
Download RDCOMClient-master.zip from https://github.com/omegahat/RDCOMClient (click the green Clone button and select download zip)
Unpack to a directory named RDCOMClient
Ensure that the following PATH variables are set:
C:\Program Files\R\R-4.0.0\bin\x64 (assuming this is the location where R is installed)
C:\Rtools\bin
C:\Rtools\mingw_64\bin
Add environment variable BINPREF with the following value (the final slash is important):
C:/Rtools/mingw_64/bin/
Open windows command prompt and change to the directory that contains the RDCOMClient subdirectory and type:
R CMD INSTALL RDCOMClient –-build RDCOMClient.zip
This installs RDCOMClient in the local installation of R-4.0.0 and additionally creates the file RDCOMClient_0.94-0.zip that can be installed on other systems using the following command:
install.packages("RDCOMClient_0.94-0.zip", repos = NULL, type = "win.binary")
I am using R 4.1.2 and I found RDCOMClient will crash the R Session and the above solutions were not working.
Then, I further check with the source owner and found out the solution.
https://github.com/omegahat/RDCOMClient/issues/36
Duncantl gave the solution and it works.
dir.create("MyTemp")
remotes::install_github("BSchamberger/RDCOMClient", ref = "main", lib = "MyTemp")
If that is successful, we can then load the newly installed package with
library("RDCOMClient", lib.loc = "MyTemp")
Using Ubuntu 14.04, I downloaded the Neon Frama-C distribution, and installed the required tools: labgtk, sourceview, etc. I configured Frama-C no problem, but on building got:
File "external/unz.ml", line 39, characters 10-19:
Error: Unbound module Z
make: *** [external/unz.cmo] Error 2
The problem is
let n = Z.of_bits str in
where Z denotes a module that is not imported (I guess). I do not know what Z is supposed to refer to so I have no way of trying to fix this.
Have you installed the zarith library (libzarith-ocaml-dev under Ubuntu)? Frama-C can use two libraries for arbitrary precision integers: either Bignum, which is included in OCaml distribution (although I wouldn't be surprised that Debian/Ubuntu did manage to make it a separate package ), or Zarith, a newer, more efficient implementation. unz.ml is part of the code that binds
Zarith to Frama-C, thus if you don't have Zarithinstalled, you will have some issues compiling it.
Normally, ./configure should take care of choosing the appropriate library. You can check what it has found in config.log. A possible issue is that you have package libzarith-ocaml installed but not libzarith-ocaml-dev. In this case, the library itself is installed (and presumably detected by ./configure), but not the headers needed to compile the code against it.