Install RPostgreSQL to connect to Postgres.app - r

I am trying to install RPostgreSQL on a Mac running OSX 10.9.5 (Mavericks) and R 13.4.0 (Darwin). I guess I don't have a running Postgres installation on my system since, from Terminal:
% which postgres
postgres not found
I use [Postgres.app][1]
I tried installing RPostgreSQL from source
library(devtools)
install('~/Downloads/rpostgresql-read-only/RPostgreSQL')
but I get the error
clang: error: unknown argument: '-Kthread'
clang: error: unknown argument: '-kthread'
make[1]: *** [fe-auth.o] Error 1
make: *** [libpq/libpq.5.dylib] Error 2
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RPostgreSQL’
Error: Command failed (1)
which is not exactly self-explanatory. I google it but I couldn't find any relations with RPostgreSQL.

I was able to do a hack install by removing the 2 -KThread flags from the MakeFile.global.darwin. I can't tell you what the -KThread flag was and why its needed, but it seemed to install fine for Mavericks (10.9.5)
PTHREAD_CFLAGS = -Kthread -kthread -pthread -pthreads -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS
changed to
PTHREAD_CFLAGS = -pthread -pthreads -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS

There's a possibly more user-friendly approach described at this blog with additional notes at the bottom of the PecanProject GitHub repo issue thread.
You'll probably have to manually link to the directory with pg_config file to address the 'libpq-fe.h' file not found issue. In my case, the command was different from that mentioned in the PecanProject issue thread:
sudo ln -s /usr/local/Cellar/postgresql/9.4.0/bin/pg_config /usr/local/bin/
I then had to
sudo ln -s /usr/local/Cellar/postgresql /usr/local/opt/postgresql
to get around a Library not loaded: /usr/local/opt/postgresql/lib/libpq.5.dylib error.
A final hat-tip to Chris Chou for that last point.

Related

Rserve : ld: library not found for -lssl

I am getting an error while trying to install Rserve 1.8.6. I can successfully install 1.7.3 from CRAN. This is on Mac OS High Sierra.
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [forward] Error 1
make: *** [all] Error 2
ERROR: compilation failed for package ‘Rserve’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rserve’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rserve’
The downloaded source packages are in
‘/private/var/folders/v7/hyxrfmk94p1_03gdrm27fnxncy3vq1/T/RtmpFHKNMe/downloaded_packages’
This worked for me (MacOS):
In terminal:
brew install openssl
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
I'm running Mac OS 10.15 Catalina, I've spent 2 days trying to fix this same problem, scouring the internet for help. I finally managed it by cobbling together solutions from a few different sources.
The key thing I was missing was that Mac OS ships with its own version of openssl which it thinks is superior to anything else you can find. It is wrong. What you need to do is go and download the latest version of openssl, install that, then export THAT library to your library path variable. Here are the steps I took with openssl 1.1.1:
Get the version number for the latest version of openssl from the source (https://www.openssl.org/source/) and then manually install it directly where it's supposed to go:
cd /usr/local/src
If you're getting "No such file or directory", make it:
cd /usr/local && mkdir src && cd src
Download openssl using curl (shown) or using the link above to the source code (make sure you put the file in the directory you just made in the previous step):
curl --remote-name https://www.openssl.org/source/openssl-1.1.1f.tar.gz
Extract and cd in:
tar -xzvf openssl-1.1.1f.tar.gz
cd openssl-1.1.1f
Compile and install (these are the 64 bit Mac OS instructions. Refer to the openssl documentation for 32 bit and other OS instructions):
./Configure darwin64-x86_64-cc shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-x86_64
make depend
sudo make install
This created a new openssl folder so when you export the library path you have to feed it the right openssl folder:
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl#1.1/lib/
Hope that helps you if you haven't figured it out yet, and anyone else in the future who is ready to chuck their computer across the room, like I was.

Error installing SP package on Linux Mint 19

I would like to know if anyone has the solution for the following SP package installation error in Linux Mint 19? Here's the error message.
/bin/bash: line 2: g++: command not found
/usr/share/R/share/make/shlib.mk:6: recipe for target 'sp.so' failed
make: *** [sp.so] Error 127
ERROR: compilation failed for package ‘sp’
Thanks, Kaio.
It seems you don’t have the g++ compiler.
Open a terminal window and try
sudo apt-get install g++
The other alternative which includes some common build libraries is
sudo apt-get install build-essencial
Then try to reinstall the R package.

can't compile beta version of igraph from github

I use DevTools tools to install
install_github("igraph/rigraph")
I can install "gaborcsardi/pkgconfig" just fine, which is also required. But "igraph/rigraph" doesn't work. I need it because I'm using an experimental package that requires this version of igraph. I get the following error:
compilation terminated.
make: *** [foreign-graphml.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-33~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="igraph.dll" SHLIB_LIBADD='$(FLIBS)' WIN=64 TCLBIN=64 ' havde status 2
ERROR: compilation failed for package 'igraph'
* removing 'C:/Users/emil/Documents/R/win-library/3.3/igraph'
Error: Command failed (1)
NOTE! the line "Warning: running command" in the code is translated by myself, since this was in my OS language which is danish. I think it is an accurate translation, but the wording might be slightly different.
I'm on a 64-bit Windows. I also have Lubuntu 16.04 installed on the same machine, and there I don't have any problems with the install. I need to use the package on a windows machine, unfortunately. RTools 3.3 is installed.
I also filed this at the github page:
https://github.com/igraph/rigraph/issues/165

gcc error when installing Statnet package

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

"Unable to compile a JNI program" when installing rJava [duplicate]

I am not able to call rJava package in R 3.0. I got the following message
Error: package ‘rJava’ was built before R 3.0.0: please re-install it
I am getting error when I tried to re-install rJava package. I have provided the output of R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.7.0_21
Java home path : /usr/lib/jvm/java-7-openjdk-i386/jre
Java compiler : /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/javac
Java headers gen.: /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/javah
Java archive tool: /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/jar
trying to compile and link a JNI progam
detected JNI cpp flags :
detected JNI linker flags :
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O2 -pipe -g -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
I am using Ubuntu 13.04. I also tried apt-get install r-cran-rjava which is not helping to solve the issue. Regarding jni.h there were some solution here. But, not sure how can I use the solution here.
I ran into the exact same issue. My solution was to install the openjdk-7-* via
sudo apt-get install openjdk-7-*
Followed that with
sudo R CMD javareconf
and I was then able to install rJava in R via install.packages("rJava").
While perhaps not the most elegant solution it appears to have solved my problems with getting rJava to work.
For those getting the error:
error: unable to load shared object '/some/dir/rJava/libs/rJava.so': libjvm.so:
cannot open shared object file: No such file or directory
I solved the error locating the library in the system and linking them to /usr/lib:
$sudo updatedb
$locate libjvm.so
/usr/lib/debug/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/debug/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/zero/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/jamvm/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/zero/libjvm.so
$sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so /usr/lib/
Installing rJava from the distribution packages as proposed in this askUbuntu answer also works:
sudo apt-get install r-cran-rjava
NOTE: tried from a Debian system.
I was also facing same error which was on RHEL8.1 & i resolved it as follows:
yum --enablerepo=* install java-1.8*
later i ran same command which was giving me error logs of R server.
R CMD javareconf
which turns into following output.

Resources