gcc error when installing Statnet package - r

Installing statnet on mac 10.10.3 with R 3.2.x (RStudio 0.99.441).
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: *** [latentnet.so] Error 1
ERROR: compilation failed for package ‘latentnet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/latentnet’
Warning in install.packages :
installation of package ‘latentnet’ had non-zero exit status
ERROR: dependency ‘latentnet’ is not available for package ‘statnet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/statnet’
Warning in install.packages :
installation of package ‘statnet’ had non-zero exit status
I tried updating XCode/Command Line Tools. Also tried not installing dependencies. I have been able to install other packages, such as ergm and sna.
It looks like the install is looking for the GCC folder and not finding it.
whereis gcc
reveals that my gcc is in /usr/bin/gcc
It looks like the install is looking for it in /usr/local/lib/gcc/
Is there a way to fix this?

This is a compilation error that you only get if you are trying to install packages from source, or when a package requires a library to be compiled from source. Normally, if you don’t use the latest version of R, you can install statnet from binary and thus R won’t have to compile the source package.
The version you are mentioning at the beginning of your message (0.99.441) is the version of your R-Studio, and not R. The version of your R is 3.2.x (Hence its address in the Library folder: /Library/Frameworks/R.framework/Versions/3.2/Resources…). Before trying to fix the compilation error you may want to try to roll back your R to a version like 3.1.2 or 3.1.3 on which you can probably download and install statnet in binary format.
For the compiler, my guess is that even if you fix the address of your gcc with a symlink, you will still get an error about gfortran or the version of gcc. Once I solved this issue by installing R and the right version of gcc through Homebrew, but right now I don’t have the possibility to try the solution and tell you exactly how.
My experience (on Yosemite) is that if you use 3.1.2 or 3.1.3, even if there is need for compilation, the error with gcc won’t occur.

sudo mkdir /usr/bin/lib && sudo ln -s /usr/bin/gcc /usr/bin/lib/gcc
Creates a new directory in /usr/bin called `lib' and creates a symbolic link to gcc in that new directory.
If that doesn't fix the error, you can undo it with:
sudo rm -i /usr/bin/lib/gcc && sudo rm -id /usr/bin/lib

Related

Installing systemfonts package from CRAN and GitHub fails

I recently upgraded my intel MacBook from Catalina to Monterey (Darwin release 21.1.0) I also upgraded R from 4.0.1 to 4.1.1 via home-brew. I have reinstalled the majority of packages necessary for my work, however, ran into issues with mapview. It failed to install due to an issue with a dependency - systemfonts. I attempted to install systemfonts directly from CRAN and after that failed from GitHub which also failed with these messages:
/bin/sh: I/usr/local/Cellar/r/4.1.1_1/lib/R/include: No such file or directory
make: [mac/FontManagerMac.o] Error 127 (ignored)
and
clang: error: no such file or directory: 'mac/FontManagerMac.o'
make: *** [systemfonts.so] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/usr/local/lib/R/4.1/site-library/systemfonts’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/85/56q39hqj2_gf31m9mbln7hhw0000gn/T//RtmpJGiNgA/file324134b404c/systemfonts_1.0.3.9000.tar.gz’ had non-zero exit status
I'd appreciate any thoughts on this issue. I may open an issue on GitHub r-lib/systemfonts as this may be related to some sort of incompatibility between the package and the updated OS however, thought I should start here.
Thanks
The solution listed in the issue from #Kevin_Cazelles linked to worked on my computer. Seems like it has something to do with gcc and R's call for the compiler.
This worked for me:
brew reinstall gcc
brew link --overwrite gcc
and then this in R-studio terminal
withr::with_makevars(c(OBJCXX = "gcc"), install.packages('systemfonts'))
In the bash shell:
sudo apt install libfontconfig1-dev
in RStidio
install.packages("systemfonts", dependencies = TRUE)

Cannot install nloptr (R 4.0.3, Ubuntu 20.04)

I tried to install nloptr on R 4.0.3, however I get this error:
/usr/bin/ld: /usr/local/lib/libnlopt.a(general.o): relocation R_X86_64_TPOFF32 against `nlopt_srand_called' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libnlopt.a(mt19937ar.o): relocation R_X86_64_TPOFF32 against `mti' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libnlopt.a(timer.o): relocation R_X86_64_TPOFF32 against `start_inited.4301' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/home/giovanni/R/x86_64-pc-linux-gnu-library/4.0/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
Can someone point me to a solution?
Thanks in advance.
The latest (2.6.2) package of libnlopt-dev is broken in Ubuntu 20, for some reason it is compiled into a static library (.so shared object is missing)
I faced the similar problem a couple of days ago. The quick fix is to download NLOPT fron Github and compile it yourself
https://nlopt.readthedocs.io/en/latest/NLopt_Installation/
At least, it worked for me.
I had a slightly related issue with this package, apt install cmake which was suggested by cli itself fixed the issue.
I also failed to install the nloptr but had another error.
g++: error: nlopt/lib/libnlopt.a: No such file or directory
I followed others suggestion to install the nlopt first as described in nlopt website. The installation process was
mkdir build
cd build
cmake ..
make
sudo make install
But I found the cmake version which nlopt needed should be higher than 3. The default cmake in my computer was version 2.8.12.2 which was /usr/bin/cmake. So I installed cmake version 3.24.2 in my home directory and compiled the nlopt using absolute path of cmake as ~/software/install/cmake-3.24.2-linux-x86_64/bin/cmake ... And I used sudo to install the nlopt in the computer. I could see the libnlopt.so libnlopt.so.0 libnlopt.so.0.11.1 files in /usr/local/lib64
When I went back to install the nloptr in R. It still failed. I found the cmake failure in the output information of installation. So I add the cmake(version 3.24.2) to my PATH in .bashrc file and then I installed the nloptr successfully.

Where should I search for the installed R packages by conda?

I am installing r packages using conda. It works fine when I use this example format
"conda install -c r r-scales --name condaenv"
But when I want to define installtion directory using --prefix
conda install -c r r-scales --prefix=/opt/local
the package "scale" is installed but I cannot find it in the directory I expect to be
"/opt/local/lib/R/library"
. It is weird because when I try to reinstall this package it says
All requested packages already installed.
that means this package is already installed in defined path. BUT WHERE?
I also try using
conda list
But I cannot find "scales" among installed packages.
UPDATE:
I also tried to use install.packages("scales), but I ran into this error
/opt/anaconda/bin/x86_64-conda_cos6-linux-gnu-ld: cannot find -lm
collect2: error: ld returned 1 exit status make: ***
[/raid60/raid2/opt/local/lib/R/share/make/shlib.mk:6: scales.so] Error
1 ERROR: compilation failed for package ?scales?
* removing ?/raid60/raid2/opt/local/lib/R/library/scales?

OSX Installing Rsymphony - linking headers and libs

symphony is correctly installed and tested in terminal. R complains about missing header and libraries when trying to install Rsymphony from source. Any pointers are HIGHLY appreciated. thank you!
symphony installation directory: /Users/timo/Applications/symphony/
R install command:
install.packages("Rsymphony", configure.args="--with-SYMPHONY-include=/Users/timo/Applications/symphony/include/ --with-SYMPHONY-lib=/Users/timo/Applications/symphony/lib",type="source")
results in :
* installing *source* package ‘Rsymphony’
** package ‘Rsymphony’ successfully unpacked and MD5 sums checked
Cannot find SYMPHONY libraries and headers.
See <https://projects.coin-or.org/SYMPHONY>.ERROR: configuration failed for package ‘Rsymphony’* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rsymphony’* restoring previous‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rsymphony’
I also struggled to get Rsymphony installed, but finally got it working after many hours of messing around. Here's what I did, hopefully it'll save others some time. This works on Mac OS El Capitan (10.11) and R 3.3.0.
First, install the homebrew package manager if you don't already have it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Next install SYMPHONY with homewbrew. I found this to be the best approach because it puts everything in the right place:
brew tap coin-or-tools/coinor
brew install symphony
Now install pkg-config, a tool for querying installed libraries for when compiling software source code. Not sure if this is strictly necessary, but pkg-config is used in the configuration script for Rsymphony:
brew install pkg-config
At this point Rsymphony should now be able to find the necessary SYMPHONY libraries, however, I still got the following compiler error:
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
Apparently it has something to do with needing a different version of the fortran compiler. This helpful post with instructions for getting the correct compiler saved me. Run the following commands:
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
Now, finally, you should be able to install Rsymphony with:
install.packages("Rsymphony", type = "source")
SOLUTION:
I have found the solution in this link (...I got RSymphony to install, but it involved some hacking ...)
Installing RSymphony using RStudio on macOS
I had also this issue: ..no checking for COIN-OR package CoinUtils... and it was solved by "export PKG_CONFIG=/usr/local/bin/pkg-config; export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/"

Unable to install rJava on R platform

I have Ubuntu 10.x OS and I have installed R on it. I want to install rJava on R. For that when I am running installed.packages("rJava) command which is giving error
checking whether Java run-time works... Error: Could not find or load main class getsp
no
configure: error: Java interpreter '/usr/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/hduser/R/i486-pc-linux-gnu-library/2.10/rJava’
The downloaded packages are in
‘/tmp/Rtmp0tlBXn/downloaded_packages’
Warning message:
In install.packages("rJava") :
installation of package 'rJava' had non-zero exit status
If I run system("java -version")
Then it showing same Java version which is given when I run Java -version command from base OS prompt. So it means no problem with Java which I can see reason in output of install package command? As suggested when I use
sudo apt-get install r-cran-rjava
Here also didnt get any luck
Please suggest
I just saw that you wrote installed.packages instead of install.packages, you have to use install.packages("rJava") to install it.
The description of the method you used (installed.packages) says: Find (or retrieve) details of all packages installed in the specified libraries.
Can you please try
install.packages("rJava")
library(rJava)
and tell me the output? (I'm pretty sure it will already work then).
in the terminal run sudo apt-get install default-jdk
then run sudo R CMD javareconf
after that you can continue in R or Rstudio install.packages("rJava")

Resources