compile rJava with jdk1.8.0_05 - rjava

I am trying to compile rJava using on OSX 10.7.5
install.packages("rJava",type="source")
The motive is this. I am using code compiled with jdk1.8.0_05 and call it using rJava. When I do this there is a mismatch between the class file version of code compiled with jdk1.8.0_05 and the class files rJava recognizes.
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/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/../include -
I/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/../include/darwin -
fno-common -
I/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/../include -
I/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/../include/darwin
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’
I have installed xz using homebrew but that didn't help.
Can I not use rJava to call code compiled with jdk1.8.0_05 ?
rJava binaries are installed and working properly. It is the source compilation that causes this.
I have executed R CMD javareconf.
Java interpreter : /usr/bin/java
Java version : 1.8.0_05
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on OS X
trying to compile and link a JNI progam
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -
DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/../include -
I/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/../include/darwin -
I/usr/local/include -fPIC -mtune=core2 -g -O2 -c conftest.c -o conftest.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 conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre
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.

You need a library: "library not found for -llzma"
Try download and install XZ 5.0.7: http://macpkg.sourceforge.net/

Related

Set include directory for linker (ld) on OSX

I have a problem with linking a compiled program (see github repo for details).
The osx specific makefile section is here:
CFLAGS = -v -arch x86_64 -Wall -fPIC -O2 -I./include $(OPTS)
LDFLAGS = -v -arch x86_64 -lpthread /usr/local/lib/libportaudio.a -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon
EXECUTABLE ?= squeezelite-osx
include Makefile
The compilation works fine, but during the linking it fails with:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -o squeezelite-osx main.o slimproto.o buffer.o stream.o utils.o output.o output_alsa.o output_pa.o output_stdout.o output_pack.o decode.o flac.o pcm.o mad.o vorbis.o faad.o mpg.o dsd.o dop.o dsd2pcm/dsd2pcm.o process.o resample.o -lpthread /usr/local/lib/libportaudio.a -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon -lFLAC -lmad -lvorbisfile -lfaad -lmpg123 -lsoxr -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a
ld: library not found for -lFLAC
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [squeezelite-osx] Error 1
The library which is not found is in the folder /usr/local/include and I think I have to add this path to the include path of the linker.
How can I add the path /usr/local/include to the include path of the linker?
The linker doesn't use include files; that's the compiler (actually the pre-processor, but let's keep it simple).
Instead you need to tell the linker that it should look in /usr/local/lib using the -L option:
-L/usr/local/lib
Note: you can provide more than one -L option to the linker.

Building GCC-4.9.2 on OS X Yosemite

Ok, I'm having trouble building gcc-4.9.2 on Apple's new OS X Yosemite. I'm not sure if I need to be building a gnu-gcc compiler on OS X, as most other software has compiled fine, apart from tesseract-3.0.1 and some of my own wxWidgets applications. Are there certain programs/code features that clang can't compile?
My build steps are as follows:
cd build-gcc
../gcc-4.9.1/configure --program-prefix="gnu-" --prefix="/usr/local/gcc-4.9.1" --with-gmp="/usr/local" --with-mpfr="/usr/local" --with-mpc="/usr/local" CC=clang CXX=clang++
make
My build path and gcc source paths do not contain any whitespace, and I have installed GMP, MPFR and MPC in /usr/local.
My build outputs are:
clang++ -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -Wl,-no_pie -o cc1 c/c-lang.o c-family/stub-objc.o attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o c/c-convert.o c/c-aux-info.o c/c-objc-common.o c/c-parser.o c/c-array-notation.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-cilkplus.o c-family/array-notation-common.o c-family/cilk.o c-family/c-ubsan.o i386-c.o darwin-c.o \
cc1-checksum.o libbackend.a main.o tree-browser.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a ./../intl/libintl.a -liconv ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -lmpc -lmpfr -lgmp -L../zlib -lz
ld: warning: ld: warning: ld: warning: ignoring file libbackend.a, file was built for archive which is not the architecture being linked (x86_64): libbackend.aignoring file libcommon-target.a, file was built for archive which is not the architecture being linked (x86_64): libcommon-target.aignoring file ../libdecnumber/libdecnumber.a, file was built for archive which is not the architecture being linked (x86_64): ../libdecnumber/libdecnumber.a
ld: warning: ignoring file ../zlib/libz.a, file was built for archive which is not the architecture being linked (x86_64): ../zlib/libz.a
Undefined symbols for architecture x86_64:
... (Lots of symbols)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [cc1] Error 1
make[2]: *** [all-stage1-gcc] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2
Configure outputs the build type as: x86_64-apple-darwin14.0.0, so I don't understand why this is happening.
Thank You in advance for any help.
Turns out that I had a broken ranlib in /usr/local/bin - maybe GNU Binutils don't work on OS X? All I needed to do to fix the problem was to:
sudo mv /usr/local/bin/ranlib /usr/local/ranlib_old
and then make, and now I have a working GCC!

How to run hello world FUSE program on Xcode

I would like to know the configurations to run this Hello World program on Xcode. I have installed MacOSXFUSE.
With the command
gcc -Wall hello.c `pkg-config osxfuse --cflags --libs` -o hello
and then with
./hello outputdrive -f -s
I am able to successfully mount the drive outputdrive.
I have environmental variable declare set as -x PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
MacOSXFUSE is installed in /usr/local/include/osxfuse/
More information:
/usr/local/lib/pkgconfig/osxfuse.pc
data in this file is
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: fuse
Description: OSXFUSE
Version: 2.7.3
Libs: -L${libdir} -losxfuse -pthread -liconv
Cflags: -I${includedir}/osxfuse/fuse -D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE
A little progress,
I did this on terminal,
pkg-config osxfuse --cflags --libs
Pasted the below result in "other c flags" in xocde
-D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE -I/usr/local/include/osxfuse/fuse -L/usr/local/lib -losxfuse -pthread -liconv
Now I get the below error,
Undefined symbols for architecture i386:
"_fuse_main_real", referenced from:
_main in main.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please let me know if more details is required.
You need to put the /usr/local/lib in the "Library search paths" and the library "libosxfuze" to the "Linked Frameworks and Libraries".
does it compile from command line?
g++ hello.c -I/usr/local/include/osxfuse/fuse -D_FILE_OFFSET_BITS=64 -v -L/usr/local/lib -losxfuse

ld: unknown option: -reexported_symbols_list when building libc++ on mac os x 10.6.8

Any suggestions for resolving the following error (unknown option passed to ld) will be highly appreciated. The "buildit" script is the one from http://libcxx.llvm.org/ with the line
export TRIPLE=-apple-
added to it.
Thanks in advance
System Version: Mac OS X 10.6.8 (10K549)
$ clang++ -v
clang version 3.4 (trunk 192978) (llvm/trunk 192977)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
/usr/local/libcxx/lib: sudo ./buildit
for FILE in '../src/*.cpp'
clang++ -c -g -Os -arch i386 -arch x86_64 -nostdinc++ -std=c++11 -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion -Wpadded -Wstrict-aliasing=2 -Wstrict-overflow=4 -U__STRICT_ANSI__ -I../include ../src/algorithm.cpp
for FILE in '../src/*.cpp'
...
clang algorithm.o bind.o chrono.o condition_variable.o debug.o exception.o future.o hash.o ios.o iostream.o locale.o memory.o mutex.o new.o optional.o random.o regex.o shared_mutex.o stdexcept.o string.o strstream.o system_error.o thread.o typeinfo.o utility.o valarray.o -arch i386 -arch x86_64 -o libc++.1.dylib -dynamiclib -nodefaultlibs -current_version 1 -compatibility_version 1 -install_name /usr/lib/libc++.1.dylib -lSystem -Wl,-unexported_symbols_list,libc++unexp.exp /usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp -Wl,-force_symbols_not_weak_list,notweak.exp -Wl,-force_symbols_weak_list,weak.exp -nostdinc++ -std=c++11 -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion -Wpadded -Wstrict-aliasing=2 -Wstrict-overflow=4 -U__STRICT_ANSI__
clang: warning: argument unused during compilation: '-nostdinc++'
clang: warning: argument unused during compilation: '-std=c++11'
ld: unknown option: -reexported_symbols_list
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've been struggling for days with the same problem, but eventually got it compiled.
Before running the build script, try setting the following environment variables:
export TRIPLE=-apple-
export MACOSX_DEPLOYMENT_TARGET=10.6

Install fortran-based R package on Mac OS X

I'm attempting to install version 1.10 of the cts package from CRAN on OS X, and I'm running into some linker problems. I need to install from source, because I'm making a few changes to the source (actually Zhu Wang, the cts author, made the changes & sent me the new tarball - but the same issue happens with the stock sources of cts on CRAN).
It seems to compile all the sources fine, but then fails with the following errors during linking:
> install.packages('~/Downloads/cts_1.0-11.tar.gz', .libPaths()[1], repos=NULL, type='source')
* installing *source* package ‘cts’ ...
** libs
*** arch - i386
gfortran-4.2 -arch i386 -fPIC -g -O2 -c a9rntc.f -o a9rntc.o
gfortran-4.2 -arch i386 -fPIC -g -O2 -c a9rntd.f -o a9rntd.o
gfortran-4.2 -arch i386 -fPIC -g -O2 -c a9rnti.f -o a9rnti.o
[bunch of other compilation lines snipped ...]
gfortran-4.2 -arch i386 -fPIC -g -O2 -c u9dmp.f -o u9dmp.o
gfortran-4.2 -arch i386 -fPIC -g -O2 -c update.f -o update.o
gcc-4.2 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o cts.so a9rntc.o a9rntd.o a9rnti.o a9rntl.o a9rntr.o balanc.o balinv.o cinvert.o complete.o cspec.o d1mach.o d1rply.o d2rply.o d3rply.o d4rply.o d5rply.o d6rply.o d7rply.o d8rply.o d9rply.o dgetrf.o dgetrs.o display.o dpca.o drpoly.o e9rint.o envirn.o eprint.o fdump.o forecast.o frmatd.o frmati.o frmatr.o getmin.o hqrort.o i0tk00.o i10wid.o i1mach.o i8save.o iceil.o iflr.o isamax.o istkgt.o istkqu.o istkrl.o kfilsm.o kfilsm1.o loop.o lybsc.o lycsr.o mepad.o mutil.o newline.o orthes.o ortran.o rejuce.o repar.o resg0.o resg0new.o resg1d.o resg1dpre.o resg1dpre1.o resgen.o revg1.o roots.o s88fmt.o saxpy.o sdata.o sdot.o sdump.o search.o setcom.o seterr.o setfor.o setkfilsm.o setup1.o setupdate.o simi.o sscal.o stkdmp.o store.o u9dmp.o update.o -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRlapack -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRblas -lgfortran -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: can't find atom for N_GSYM stabs mdeps:G(0,10)=s32base:(0,6),0,64;big:(0,6),64,64;small:(0,6),128,64;eps:(0,6),192,64;; in balanc.o
ld: warning: can't find atom for N_GSYM stabs base:G(0,6) in balanc.o
ld: warning: can't find atom for N_GSYM stabs setcon:G(0,3)=s252cso:(0,4)=r(0,2);8;0;,0,64;csz:(0,4),64,64;lam:(0,4),128,64;ssold:(0,4),192,64;gmold:(0,4),256,64;gmnew:(0,4),320,64;sigsq:(0,4),384,64;oldb:(0,5)=ar(0,2);0;21;(0,4),448,1408;conv:(0,6)=#s32;-16;,1856,32;fail:(0,6),1888,32;np:(0,2),1920,32;itct:(0,2),1952,32;ppind:(0,2),1984,32;; in cinvert.o
ld: warning: can't find atom for N_GSYM stabs cso:G(0,4) in cinvert.o
ld: warning: can't find atom for N_GSYM stabs resgn2:G(0,7)=s59364wk:(0,8)=ar(0,2);0;19;(0,4),0,1280;vt:(0,9)=ar(0,2);0;4999;(0,4),1280,320000;bi:(0,10)=ar(0,2);0;799;(0,4),321280,51200;r:(0,11)=ar(0,2);0;799;(0,4),372480,51200;ri:(0,12)=ar(0,2);0;799;(0,4),423680,51200;errno1:(0,2),474880,32;; in cinvert.o
ld: warning: can't find atom for N_GSYM stabs wk:G(0,8) in cinvert.o
ld: in cinvert.o, sectionForAddress(0xE7F0) address not in any section for architecture i386
collect2: ld returned 1 exit status
make: *** [cts.so] Error 1
ERROR: compilation failed for package ‘cts’
* removing ‘/Users/ken/R-dev/cts’
* restoring previous ‘/Users/ken/R-dev/cts’
Warning message:
In install.packages("~/Downloads/cts_1.0-11.tar.gz", .libPaths()[1], :
installation of package ‘/Users/ken/Downloads/cts_1.0-11.tar.gz’ had non-zero exit status
Are there any compile/link flags I should pass to install.packages(), maybe? What options are the CRAN binary build machines using?

Resources