R:cant install rJava in Ubuntu 12.04 - rstudio

JAVA_HOME has been set in .bashrc to java-7-openjdk where jni.h is located.
The output JAVA_HOME is overridden when reconfigured
lab#lab-Inspiron-N5010:~$ locate jni.h
/usr/lib/jvm/java-7-openjdk-i386/include/jni.h
lab#lab-Inspiron-N5010:~$ echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-i386/jre
lab#lab-Inspiron-N5010:~$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.6.0_30
Java home path : /usr/lib/jvm/java-6-openjdk-i386/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI progam
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/i386/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O3 -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_HOME : /usr/lib/jvm/java-6-openjdk-i386/jre
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
R version 3.1.0 beta (2014-03-28 r65330)
Tried all solutions suggested st R: rJava package install failing
Java version details
java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-1ubuntu2~0.12.04.1)
OpenJDK Server VM (build 23.25-b01, mixed mode)
Kindly help
[SOLVED] Downloading the packages from ubuntu cran solved the issue.
ubuntu cran

I have similar error and the reason for this error that some of the Java JDK settings are not done, so in my case I run the following commands and the installation completed successfully
update-alternatives --display jar
sudo update-alternatives --install "/usr/bin/jar" "jar" "/app/java/jdk1.7.0_51/bin/jar" 1
sudo update-alternatives --set jar /app/java/jdk1.7.0_51/bin/jar
update-alternatives --display javah
sudo update-alternatives --install "/usr/bin/javah" "javah" "/app/java/jdk1.7.0_51/bin/javah" 1
sudo update-alternatives --set javah /app/java/jdk1.7.0_51/bin/javah
also you can find the list of all Java variables and how to expose them using the below link:
http://programmaticponderings.wordpress.com/2013/12/16/updating-oracles-pre-built-enterprise-java-vm-for-development/

Related

cmake build failed on macos catalina 10.15

I have recently installed macos catalina with Xcode 11.1 and updated cmake, clang and llvm
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
$ cmake --version
cmake version 3.15.4
$ which cmake
/usr/local/bin/cmake
$ clang --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ which clang
/usr/bin/clang
The CMakeLists.txt looks as bellow:
cmake_minimum_required(VERSION 3.14)
project("ROZZETA" VERSION 0.0.1 LANGUAGES C)
# Allow us to import cmake scripts from ./cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Compiler flags
set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "")
find_package(GMP REQUIRED)
add_executable(Rozzeta main.c)
target_link_libraries(Rozzeta gmp libgmp libgmp.a)
cmake detected gmp successfully :
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=c++ -G "CodeBlocks - Unix Makefiles" /<path to project>
-- The C compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Using toolchain file: .
-- Found GMP: /usr/local/include/gmp.h and /usr/local/lib/libgmp.a
-- Configuring done
-- Generating done
build failed :
cmake --build .
Scanning dependencies of target Rozzeta
[ 50%] Building C object CMakeFiles/Rozzeta.dir/main.c.o
/Users/gajaka/CLionProjects/Rozzeta/main.c:4:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
^~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/Rozzeta.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/Rozzeta.dir/all] Error 2
make: *** [all] Error 2
I have compiled manually with:
cc main.c -lgmp
Anyone can help me with this ?
Many thanks in advance
It was very frustrating for me! I am personally using CLion from jetbrains, while tried to build old codes written in C/C++, it's giving me error because MacOS 10.15, Catalina removed the C headers pkg used to be in Mojave. So, found another way around and tried.
If you have installed XCode 11.1, then open the terminal and run the following command:
xcode-select --install
then,
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
Now, you are good to go. Try to build using cmake.
If you're calling find_package(GMP ...) in your CMake file, why not use the GMP-specific variables it populates? It looks like CMake successfully finds GMP installed on your system (based on your CMake log), so try using the GMP_* variables that should be populated:
cmake_minimum_required(VERSION 3.14)
project("ROZZETA" VERSION 0.0.1 LANGUAGES C)
# Allow us to import cmake scripts from ./cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Compiler flags
set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "")
find_package(GMP REQUIRED)
add_executable(Rozzeta main.c)
# Use the populated GMP variables here.
target_include_directories(Rozzeta PRIVATE ${GMP_INCLUDE_DIR})
target_link_libraries(Rozzeta PRIVATE ${GMP_LIB})
after
xcode-select --install
I got a clang but no cmake so I did
brew install cmake
which installed cmake for Catalina.
In order to compile programs with cmake and XCode's toolchain in Mac OS 10.15 (Catalina) you must install xcode command line utility tools + make some additional symlinks (#Roy said about it, but forgot to mention other two):
$ xcode-select --install
$ sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
$ for i in {Platforms,Toolchains,Tools}; do sudo ln -sn /Applications/Xcode.app/Contents/Developer/$i /Library/Developer/CommandLineTools/$i; done

Developer Studio 12.0.0.GA fails to launch after install

As a pre-requisite for installing JBoss EAP 7.2, I installed the Developer Studio 12.0.0.GA successfully.
However it fails to launch with the following error:
See the error message below:
*jboss#rhebsr12 $> ./devstudio
***WARNING: Gtk+ version too old (micro mismatch)
***WARNING: SWT requires GTK 2.24.0
***WARNING: Detected: 2.18.9
***WARNING: SWT requires Cairo 1.9.4 or newer
***WARNING: Detected: 1.8.8
/usr/java/jdk1.8.0_221/bin/java: symbol lookup error: /projects/home/jboss7/devstudio/studio/configuration/org.eclipse.osgi/653/0/.cp/libswt-pi-gtk-4880.so: undefined symbol: g_bus_own_name
Devstudio:
JVM terminated. Exit code=127
/usr/java/jdk1.8.0_221/bin/java
-Xms512m
-Xmx1024m
-Dosgi.instance.area.default=#user.home/workspace
-jar /projects/home/jboss7/devstudio/studio//plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
-os linux
-ws gtk
-arch x86_64
-showsplash
-launcher /projects/home/jboss7/devstudio/studio/devstudio
-name Devstudio
--launcher.library /projects/home/jboss7/devstudio/studio//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.700.v20180518-1200/eclipse_1705.so
-startup /projects/home/jboss7/devstudio/studio//plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
--launcher.overrideVmargs
-exitdata 4121001d
-product com.jboss.devstudio.core.product
-vm /usr/java/jdk1.8.0_221/bin/java
-vmargs
-Xms512m
-Xmx1024m
-Dosgi.instance.area.default=#user.home/workspace
-jar /projects/home/jboss7/devstudio/studio//plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
/projects/home/jboss7/devstudio*
Any suggestions to resolve?
Thanks,
Syed
DevStudio needs a newer version of cairo. I don't know which operating system you're running, but try to upgrade this package.
There is a similar issue reported here: https://issues.jboss.org/browse/JBDS-4707

rJava image missing in Rstudio in OsX

When I try to load library("rJava") in RStudio on OsX High Sierra, I get the error already mentioned about the image not being present:
Error: package or namespace load failed for 'rJava':
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Users/ognjenmilicevic/RPlay/Methylation_Mayo_Vesna_Garovic/libs/rJava/libs/rJava.so':
dlopen(/Users/ognjenmilicevic/RPlay/Methylation_Mayo_Vesna_Garovic/libs/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Users/ognjenmilicevic/RPlay/Methylation_Mayo_Vesna_Garovic/libs/rJava/libs/rJava.so
Reason: image not found
I tried reconfiguring Java but the error persists:
$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 10.0.1
Java home path : /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/include/darwin -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
clang -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 conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
Removing and reinstalling the package doesn't help. I tried pointing to my version by using:
dyn.load('/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')
The error persists. All the while it works in R when ran as a command. Where is the path "/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib" coming from and how can I change it to point to my installation?
It looks like you have sort of a messy installation or rJava.
You can always check which version of Java was used (while building rJava) by calling:
> otool -L /Library/Frameworks/R.framework/Resources/library/rJava/libs/rJava.so
/Library/Frameworks/R.framework/Resources/library/rJava/libs/rJava.so:
rJava.so (compatibility version 0.0.0, current version 0.0.0)
/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib (compatibility version 1.0.0, current version 1.0.0)
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libR.dylib (compatibility version 3.6.0, current version 3.6.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1259.11.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
in your case you have to call
> otool -L /Users/ognjenmilicevic/RPlay/Methylation_Mayo_Vesna_Garovic/libs/rJava/libs/rJava.so
Make sure you have this Java version installed: jdk-11.0.1.jdk. If you don't have it, and you want to install rJava with your current release of JDK - e.g.: jdk-10.0.1.jdk, follow the steps here: http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/
Also, remember that in macOS, the default Java is the newest one. It means that RStudio will pick the version with highest number - one that is enabled.
You can disable given version of Java by calling
> cd /Library/Java/JavaVirtualMachines/jdk-11.0.4.jdk/Contents
> mv Info.plist Info.plist~
Above commands will make this Java version "invisible" for macOS.
Once you follow the steps (as described in linked article) you will be able to run Java from both: R and RStudio
> R
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(rJava)
> .jinit()
> J("java.lang.System","getProperty","java.version")
[1] "11.0.3"
>

Install Perl Math::GMP on OSX

I am attempting to install the Perl package Math::GMP on OS X El Capitan.
I had one computer where this worked without issue - but a second computer is running into the following problem:
The Perl module Math::GMP requires the C library for GMP, so I have done a brew install gmp
This installed GMP including the following file:
/usr/local/include/gmp.h
But the package install still fails claiming I don't have gmp installed:
$ sudo perl -MCPAN -e shell
cpan[1]> install Math::GMP
Reading '/Users/chaosadmin/.cpan/Metadata'
Database was generated on Sat, 14 Nov 2015 09:17:02 GMT
Running install for module 'Math::GMP'
Checksum for /Users/me/.cpan/sources/authors/id/S/SH/SHLOMIF/Math-GMP-2.11.tar.gz ok
Scanning cache /Users/me/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring S/SH/SHLOMIF/Math-GMP-2.11.tar.gz with Makefile.PL
Can't link/include C library 'gmp.h', 'gmp', aborting.
No 'Makefile' created SHLOMIF/Math-GMP-2.11.tar.gz
/usr/bin/perl Makefile.PL -- NOT OK
Failed during this command:
SHLOMIF/Math-GMP-2.11.tar.gz : writemakefile NO -- No 'Makefile' created
The obvious line is:
Can't link/include C library 'gmp.h', 'gmp', aborting.
But I definitely have "gmp.h" installed in /usr/local/include/gmp.h
I'm unsure why it's failing to install on this OS X El Capitan machine (it worked fine on my other one).
In the CPAN shell I used:
look Math::GMP
And updated the Makefile.PL to debug:
check_lib_or_exit(
header => 'gmp.h',
lib => 'gmp',
debug => 'true'
);
Which displayed the following error when running perl Makefile.PL
# /usr/bin/cc -arch i386 -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -arch i386 -arch x86_64 -fstack-protector assertlibD4RJzZEa.c -o assertlibwGFzIVsM
assertlibD4RJzZEa.c:1:10: fatal error: 'gmp.h' file not found
include
On Centos :
Just install this : yum install gmp* -y
Good Luck :)

Install happstack-server 6.5.3 on osx - missing libcryptopp

I'm trying to install the latest happstack-server on osx. They just added a dependency on libcryptopp, and I can't get it working.
~$ cabal install happstack-server
Resolving dependencies...
Configuring happstack-server-6.5.3...
cabal: Missing dependency on a foreign library:
* Missing C library: cryptopp
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal: Error: some packages failed to install:
happstack-server-6.5.3 failed during the configure step. The exception was:
ExitFailure 1
So, then I install libcryptopp with macports, which puts libcryptopp.a in /opt/local/lib
sudo port install libcryptopp
Then I install happstack-server again with --extra-lib-dirs
cabal install happstack-server --extra-lib-dirs=/opt/local/lib
It installs fine, everything seems to work until I actually run a happstack server.
~$ runhaskell Hello.hs
Hello.hs: <command line>: can't load .so/.DLL for: libcryptopp.dylib (dlopen(libcryptopp.dylib, 9): image not found)
What am I doing wrong? Or is this a bug with happstack? I don't even have a .dylib after installing the lib via macports, only a .a. ghc --make Hello.hs is even crazier
How about:
g++ -fpic -nostartfiles -nostdlib -shared /usr/local/Cellar/cryptopp/5.6.1/lib/libcryptopp.a -o libcryptopp.dylib
as a brute-force approach, You can disable https flag in .cabal file of happstack-server:
file: happstack-server.cabal :
Flag https
Default: False
configure/build/install happstack-server manually, them cabal install happstack.
(I use Archlinux, --extra-lib-dirs don't even work!)

Resources