I am writing a program to talk to a USB hardware interface board, which requires a small JNI library. I am running 10.5.8 on my compile machine, and can succesfully compile the shared library for JNI with the following commands:
# Build shared library for K8055
g++ -x objective-c -fmessage-length=0 -pipe -Wno-trigraphs \
-fpascal-strings -fasm-blocks -O0 -mdynamic-no-pic -fvisibility=hidden -gdwarf-2 \
-Wmost -Wno-four-char-constants -Wno-unknown-pragmas \
-c ./K8055/K8055.m \
-o ./K8055/K8055.o \
-arch x86_64 \
-arch i386
echo "Building JNI shared library..."
gcc -c -m64 -I/System/Library/Frameworks/JavaVM.framework/Headers \
k8055usbio.m -o k8055usbio.so -arch x86_64
echo "Compiling dynamic library with both..."
g++ -m64 -dynamiclib -o ./lib/libk8055usbio.dylib \
k8055usbio.so ./K8055/K8055.o\
-framework Foundation -framework IOKit
I don't really understand what I'm doing here; I have managed to piece that together from a lot of Googling. My question is: How do I modify this to compile for a PPC G3 machine running 10.3.9? The Java part I am happy with. Here is what I've tried so far:
# Build shared library for K8055 (PPC)
echo "Building driver shared library..."
g++ -x objective-c -fmessage-length=0 -pipe -Wno-trigraphs \
-fpascal-strings -fasm-blocks -O0 -mdynamic-no-pic -fvisibility=hidden -gdwarf-2 \
-Wmost -Wno-four-char-constants -Wno-unknown-pragmas \
-c ./K8055/K8055.m \
-o ./K8055/K8055.o \
-arch ppc
echo "Building JNI shared library..."
gcc -c -I/System/Library/Frameworks/JavaVM.framework/Headers \
k8055usbio.m -o k8055usbio.so -arch ppc
echo "Compiling dynamic library with both..."
gcc -shared -fPIC -o ./lib/libk8055usbio.dylib k8055usbio.so \
./K8055/K8055.o -framework Foundation -framework IOKit -arch ppc
But when I try to System.load() it, I get the following error from the Java (1.5) program:
dyld: java bad CPU subtype in library: /libk8055usbio.dylib
Trace/BPT trap
I don't have any idea how to fix it, what CPU subtype should I be specifying?
You'll need to fiddle a couple of options. First, you'll want to explicitly specify an SDK using -isysroot, since newer SDKs will subvert you in various ways. Second, you'll want to pass -mmacosx-version-min=10.3 to indicate that you really want to run on 10.3. Using both of those options on a little test program, I get a binary that claims it ought to run on a G3. Here's my command line:
gcc-4.0 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -mmacosx-version-min=10.3 -o testprog testarch.c
You can sanity check the CPU type/subtype in the header using otool -h, which for this example gives me:
$ otool -h testprogtestprog:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
0xfeedface 18 0 0x00 2 11 1268 0x00000085
The zero there is CPU_SUBTYPE_POWERPC_ALL, per /Developer/SDKs/MacOSX10.4u.sdk/usr/include/mach/machine.h .
Related
So basically this is the error I'm having when calling rJava:
library(rJava)
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 '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so
Reason: image not found
Below are some of the R & Terminal scripts that I ran while tackling the problem:
1) This returned error as well
$ sudo R CMD javareconf
Password:
Java interpreter : /usr/bin/java
Java version : 13.0.1
Java home path : /Library/Java/JavaVirtualMachines/jdk-13.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. -ljvm
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-13.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. -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: library not found for -ljvm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [conftest.so] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
2)
> Sys.setenv(JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home')
> dyn.load('/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')
3)
$ sudo ln -f -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib
In case this helps:
> Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH")
[1] "/Library/Frameworks/R.framework/Resources/lib:/Users/paulwoo/lib:/usr/local/lib:/usr/lib:::/lib:/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server"
> Sys.getenv("DYLD_LIBRARY_PATH")
[1] "/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server"
Yet none of these solved the problem. I have reinstalled rJava package several times as well. My best guess is that this has something to do with mismatch between the versions, but I have no idea what to do.
Any other suggestions?
Use the OSX uninstaller tool to nuke your current install of JDK.
Reinstall (Open)JDK
brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk13-openj9-large
Then reconfigure RJava:
sudo R CMD javareconf
This should do the trick.
I'm trying to build the java google cloud debugger on Ubuntu 15.10 Server (guest) running on Virtual Box 5.0.14 on Mac OS X El Capitan (host).
I'm following the build instructions from cloud-debug-java
After installing cmake, build-essential, oracle java 8, maven3 etc., I also had to make the following changes to src/agent/Makefile before running ./build.sh:
Changed the /path/to/java/ to /usr/lib/jvm/java-8-oracle/
Added this include: -I/usr/lib/jvm/java-8-oracle/include/linux
So, my INCLUDES declaration looks like this:
INCLUDES = \
-I/usr/lib/jvm/java-8-oracle/include \
-I/usr/lib/jvm/java-8-oracle/include/linux \
-I$(THIRD_PARTY_INCLUDE_PATH) \
-I$(ANTLR_CPP_LIB_INCLUDE) \
-I. \
-I../codegen \
-Iantlrgen \
After that, the build runs fine but eventually fails when trying to build expression_util.o
Error:
g++ -I/usr/lib/jvm/java-8-oracle/include -I/usr/lib/jvm/java-8-oracle/include/linux -I/home/ubuntu-java/Development/google-cloud-debugger/cloud-debug-java/third_party/install/include -I../../third_party/antlr/lib/cpp/v2_7_2/ -I. -I../codegen -Iantlrgen -m64 -std=c++11 -fPIC -Werror -Wall -Wno-unused-parameter -Wno-deprecated -Wno-ignored-qualifiers -Wno-sign-compare -Wno-array-bounds -g0 -DSTANDALONE_BUILD -DGCP_HUB_CLIENT -Wno-unused-but-set-variable -Wno-strict-aliasing -O3 -D NDEBUG -c expression_util.cc -o expression_util.o
In file included from expression_util.cc:25:0:
antlrgen/JavaExpressionLexer.hpp:4:54: fatal error: third_party/antlr/lib/cpp/antlr/config.hpp: No such file or directory
compilation terminated.
Makefile:190: recipe for target 'expression_util.o' failed
make: *** [expression_util.o] Error 1
In the generated JavaExpressionLexer.hpp file, it's trying to #include third_party/antlr/lib/cpp/antlr/config.hpp and fails to find it.
In the project, I do see a config.hpp, but it's under <project-root>/third_party/antlr/lib/cpp/v2_7_2/antlr/.
I'm not sure how to resolve this error.
Are you using build.sh script? It should take care of ANTLR and other third party dependencies.
Specifically the build needs to set THIRD_PARTY_INCLUDE_PATH environment variable similarly to build.sh.
after I recently failed to Upgrade to Ubuntu 14.10 the installer put back my system to the standard 14.04 configuration (That is somewhat what it said). Now I am facing problems using rJava in R together with the OpenStreetMap package.
The output of sudo update-alternatives --config java
is;
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
3 /usr/lib/jvm/jre1.7.0/jre1.7.0_21/bin/java 3 manual mode
I then run: sudo R CMD javareconf:
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
Java interpreter : /usr/bin/java
Java version : 1.7.0_75
Java home path : /usr/lib/jvm/java-7-openjdk-amd64/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 : -I$(JAVA_HOME)/../include
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/lib/jvm/java-7-openjdk-amd64/jre/../include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR
JAVA_HOME : /usr/lib/jvm/java-7-openjdk-amd64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib/R
Done.
However, if I start working in R I get the message:
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
OpenStreetMap throws the following error:
java.lang.NullPointerException
at edu.cens.spatial.RTileController.getTileValues(RTileController.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at RJavaTools.invokeMethod(RJavaTools.java:386)
Error in osmtile(x, y, zoom, type) : could not obtain tile: 39746 1 2
What can I do? The script I use is unchanged for since long time and worked fine before (I am not sure whether the failed upgrade is related to the error)
I'm trying to use AES via the Crypto++ package from Java. Therefore I have two native methods encrypt and decrypt in my Java code which are then wrapped by C in order to access the C++ methods.
Running my C++ program from the command line works, but calling it from Java via JNI fails with an undefined symbol error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/yves/temp/lib/libCI3CppEncryptionTools.so: /home/yves/temp/lib/libCI3CppEncryptionTools.so: undefined symbol: _ZTIN8CryptoPP6FilterE
I'm compiling it via:
g++ -c -Icryptopp562 -O3 -fwhole-program -fdata-sections -ffunction-sections -fPIC -fpermissive CI3CppEncryptionToolsImpl.cpp -Lcryptopp562 -lcryptopp
gcc -I${JAVA_HOME}/include -O3 -fwhole-program -fdata-sections -ffunction-sections -Wall -shared -fPIC -o libCI3CppEncryptionTools.so CI3CppEncryptionTools.c CI3CppEncryptionToolsImpl.o -Wl,--gc-sections
So first the C++ part and then combined with the C wrapper. -fdata-sections, -ffunction-sections and -Wl,--gc-sections were my attempt to strip dead code because I thought maybe JNI does not like unused or unreferenced code.
I checked if the symbol is undefined by using:
nm lib/libCI3CppEncryptionTools.so | grep _ZTIN8CryptoPP6FilterE
U _ZTIN8CryptoPP6FilterE
And yes, it is. But why is my C++ command line program working? Checking this yields the same result.
I also looked the symbol up:
c++filt _ZTIN8CryptoPP6FilterE
typeinfo for CryptoPP::Filter
The header for CryptoPP::Filter is included. I'm curious why it says U when checking for the symbol.
Does anyone have any idea what could cause the problem or where to look next to solve the problem? Any hints/insights are highly welcome!
Compile your CI3CppEncryptionTools.c first, then link its .o into the .so. You are linking the .c
Edit: Statically link your cryptocpp library into your shared library via : -Wl,--whole-archive libcryptocpp.a -Wl,--no-whole-archive
gcc -I${JAVA_HOME}/include -O3 -fwhole-program -fdata-sections -ffunction-sections -Wall -shared -fPIC -o libCI3CppEncryptionTools.so CI3CppEncryptionTools.c CI3CppEncryptionToolsImpl.o -Wl,--whole-archive libcryptocpp.a -Wl,--no-whole-archive -Wl,--gc-sections
I always forgot to link the Crypto++ library in the second step (actually I did it in the first step, which was complete nonsense). Those two commands compile the library a-ok!
g++ -c -Icryptopp562 -O3 -fPIC -fpermissive CI3CppEncryptionToolsImpl.cpp
gcc -I${JAVA_HOME}/include -O3 -shared -fPIC -o libCI3CppEncryptionTools.so CI3CppEncryptionTools.c CI3CppEncryptionToolsImpl.o -lcryptopp
When installing rJava using install.packages("rJava") I get several errors.
lm-mb:~ lisa$ R
R Under development (unstable) (2013-11-21 r64282) -- "Unsuffered Consequences"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.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.
> install.packages("rJava")
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://www.stats.bris.ac.uk/R/src/contrib/rJava_0.9-4.tar.gz'
Content type 'application/x-gzip' length 498108 bytes (486 Kb)
opened URL
==================================================
downloaded 486 Kb
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... llvm-gcc-4.2 -arch x86_64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether llvm-gcc-4.2 -arch x86_64 -std=gnu99 accepts -g... yes
checking for llvm-gcc-4.2 -arch x86_64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... llvm-gcc-4.2 -arch x86_64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether llvm-gcc-4.2 -arch x86_64 -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver : '/usr/bin/jar'
compiler : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags : '-I/System/Library/Frameworks/JavaVM.framework/Headers'
java libs : '-framework JavaVM'
checking whether JNI programs can be compiled... yes
checking JNI data types... ok
checking whether JRI should be compiled (autodetect)... yes
checking whether debugging output should be enabled... no
checking whether memory profiling is desired... no
checking whether threads support is requested... no
checking whether callbacks support is requested... no
checking whether JNI cache support is requested... no
checking whether JRI is requested... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
=== configuring in jri (/private/var/folders/dn/lvhnwvq15n37bdh0dqm033zh0000gp/T/RtmpuD563L/R.INSTALL158732c239a6c/rJava/jri)
configure: running /bin/sh ./configure '--prefix=/usr/local' --cache-file=/dev/null -- srcdir=.
checking build system type... i386-apple-darwin12.5.0
checking host system type... i386-apple-darwin12.5.0
checking for gcc... llvm-gcc-4.2 -arch x86_64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether llvm-gcc-4.2 -arch x86_64 -std=gnu99 accepts -g... yes
checking for llvm-gcc-4.2 -arch x86_64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... llvm-gcc-4.2 -arch x86_64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking whether Java interpreter works... checking whether JNI programs can be compiled... yes
checking whether JNI programs can be run... yes
checking JNI data types... ok
checking whether Rinterface.h exports R_CStackXXX variables... yes
checking whether Rinterface.h exports R_SignalHandlers... yes
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating Makefile
config.status: creating run
config.status: creating src/config.h
** libs
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c Rglue.c -o Rglue.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c arrayc.c -o arrayc.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c callJNI.c -o callJNI.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c callback.c -o callback.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c fields.c -o fields.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c init.c -o init.o
init.c: In function ‘initJVM’:
init.c:100: warning: ‘JNI_GetDefaultJavaVMInitArgs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1934)
init.c:139: warning: ‘JNI_CreateJavaVM’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1937)
init.c: In function ‘RinitJVM’:
init.c:278: warning: ‘JNI_GetCreatedJavaVMs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1940)
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c jri_glue.c -o jri_glue.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c loader.c -o loader.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c otables.c -o otables.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c rJava.c -o rJava.o
rJava.c: In function ‘getJNIEnv’:
rJava.c:200: warning: ‘JNI_GetCreatedJavaVMs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1940)
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c tools.c -o tools.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o rJava.so Rglue.o arrayc.o callJNI.o callback.o fields.o init.o jri_glue.o loader.o otables.o rJava.o tools.o -framework JavaVM -F/Library/Frameworks/R.framework/.. - framework R -Wl,-framework -Wl,CoreFoundation
(cd ../jri && make)
make -C src JRI.jar
/usr/bin/javac -target 1.4 -source 1.4 -d . ../Mutex.java ../RBool.java ../RConsoleOutputStream.java ../REXP.java ../RFactor.java ../RList.java ../RMainLoopCallbacks.java ../RVector.java ../Rengine.java ../package-info.java
/usr/bin/javah -d . -classpath . org.rosuda.JRI.Rengine
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rengine.o Rengine.c -g -Iinclude - DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2 - I/System/Library/Frameworks/JavaVM.framework/Headers -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o jri.o jri.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2 -I/System/Library/Frameworks/JavaVM.framework/Headers -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rcallbacks.o Rcallbacks.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2 -I/System/Library/Frameworks/JavaVM.framework/Headers -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
Rcallbacks.c: In function ‘checkEnvironment’:
Rcallbacks.c:46: warning: ‘JNI_GetCreatedJavaVMs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1940)
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rinit.o Rinit.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2 -I/System/Library/Frameworks/JavaVM.framework/Headers -fno-common -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o globals.o globals.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2 -I/System/Library/Frameworks/JavaVM.framework/Headers -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o rjava.o rjava.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2 -I/System/Library/Frameworks/JavaVM.framework/Headers -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -o libjri.jnilib Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o -dynamiclib -framework JavaVM -F/Library/Frameworks/R.framework/.. -framework R -llzma -licucore -lm -liconv
ld: library not found for -llzma
collect2: ld returned 1 exit status
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava’
The downloaded source packages are in
‘/private/var/folders/dn/lvhnwvq15n37bdh0dqm033zh0000gp/T/Rtmp5B1vEJ/downloaded_packages’
Warning message:
In install.packages("rJava") :
installation of package ‘rJava’ had non-zero exit status
The first reports that I am missing the library associated with lzma. A bit of googling tells me this library, liblzma, is associated with XY file compression? XZ Compression Tukaani Is this correct, if so where can I obtain this library?
I do not know why the other errors occur when attempting to build? I am guessing they are associated with my Java environment?
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
I have updated my Java version and am now running the latest.
lm-mb:~ lisa$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
I also see that libjdns_sd.jnilib is also found
lm-mb:jre lisa$ ls /usr/lib/java/
libjdns_sd.jnilib
I have also set my JAVA_HOME environment according to this post R: rJava package install failing
export JAVA_HOME=$/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
export JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
export PATH
Would greatly appreciate any help.
I ran into the same issue and I seem to have got through it by installing the mac binary version like so:
install.packages("rJava", type="mac.binary")
If you really need to use that lzma library you might have luck installing it via MacPorts:
sudo port install lzma
I'm on OS X 10.6.8 (Snow Leopard).
For linux users (tested on 14.04):
I had similar issue, but in my environment, I use java 1.6. I resolved it by installting the missing lzma library
sudo apt-get install liblzma-dev
Hope it helps someone :) Cheers