Я установил graalvm-ce-java8-20.0.0 на MacOS Catalina. Я могу запустить простой код R из java:
Context context = Context.newBuilder("js").allowAllAccess(true).build();
Context.newBuilder().allowNativeAccess(true).build();
Set<String> languages = context.getEngine().getLanguages().keySet();
System.out.println("Current Languages available in GraalVM: " + languages);
context.eval("js","print('JavaScript: Hello World')");
Context rcontext = Context.newBuilder("R")
.allowAllAccess(true)
.allowHostClassLoading(true)
.allowIO(true)
.allowNativeAccess(true)
.allowCreateThread(true)
.build();
rcontext.eval("R", "print('R: Hello World');");
int result = rcontext.eval("R", "sum").execute(new int[] {3,4,5}).asInt();
System.out.println("result: " + result);
Когда я пытаюсь установить почти любую библиотеку R, например. R cpp:
source = Source.create("R", "install.packages(\"Rcpp\");");
String text = rcontext.eval(source).asString();
У меня следующая ошибка:
> installing to
> /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs
> ** R
> ** inst
> ** byte-compile and prepare package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** installing vignettes
> ** testing if installed package can be loaded from temporary location
com.oracle.truffle.r.runtime.ffi.DLL$DLLException: unable to load shared object '/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so'
dlopen(/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so, 6): Symbol not found:
__ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
Referenced from: /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
Expected in: flat namespace
in /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
at com.oracle.truffle.r.runtime.ffi.DLL$LoadPackageDLLNode.doLoad(DLL.java:704) ...
>
> at org.graalvm.polyglot.Context.eval(Context.java:345)
> at com.oracle.truffle.r.launcher.REPL.lambda$readEvalPrint$1(REPL.java:124)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.lang.UnsatisfiedLinkError: dlopen(/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so,
> 6): Symbol not found:
> __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
> Referenced from: /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
> Expected in: flat namespace
> in /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
> at com.oracle.truffle.nfi.impl.NFIContext.loadLibrary(Native Method)
> at com.oracle.truffle.nfi.impl.NFIContext.loadLibrary(NFIContext.java:170)
> at com.oracle.truffle.nfi.impl.NFILanguageImpl$LoadLibraryNode.execute(NFILanguageImpl.java:147)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callProxy(OptimizedCallTarget.java:474)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callRoot(OptimizedCallTarget.java:449)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:419)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:403)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:349)
> at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:67)
> at com.oracle.truffle.nfi.NFIRootNode.execute(NFIRootNode.java:106)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callProxy(OptimizedCallTarget.java:474)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callRoot(OptimizedCallTarget.java:449)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:419)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:403)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callIndirect(OptimizedCallTarget.java:330)
> at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.call(OptimizedCallTarget.java:320)
> at com.oracle.truffle.r.ffi.impl.nfi.TruffleNFI_DLL.dlOpen(TruffleNFI_DLL.java:77)
> at com.oracle.truffle.r.ffi.impl.nfi.TruffleNFI_DLL$TruffleNFI_DLOpenNode.execute(TruffleNFI_DLL.java:64)
at com.oracle.truffle.r.runtime.ffi.DLL$LoadPackageDLLNode.doLoad(DLL.java:699)
... 509 more
Caused by: Attached Guest Language Frames (0)
Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so'
dlopen(/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so,
6 ): Символ не найден: __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev Ссылка на: /libs/Rcpp.so Ожидается в: плоском пространстве имен в /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK- Rcpp / 00new / Rcpp / libs / R cpp .so Ошибка: загрузка не удалась
На той же машине у меня есть Rstudio, где я могу без проблем устанавливать любые пакеты.
Это вывод $ GRAALVM_HOME / bin / R -e 'install.packages ("R cpp", type = "source")':
install.packages("Rcpp", type="source")
Content type 'application/octet-stream' length 3635277 bytes (3.5 MB)
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/bin/gcc-7 -I"/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/include" -DNDEBUG -I../inst/include/ -O2 -DFASTR -DNO_GNUR -fPIC -O2 -DFASTR -DNO_GNUR -c Date.cpp -o Date.o
/usr/local/bin/gcc-7 -I"/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/include" -DNDEBUG -I../inst/include/ -O2 -DFASTR -DNO_GNUR -fPIC -O2 -DFASTR -DNO_GNUR -c Module.cpp -o Module.o
/usr/local/bin/gcc-7 -I"/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/include" -DNDEBUG -I../inst/include/ -O2 -DFASTR -DNO_GNUR -fPIC -O2 -DFASTR -DNO_GNUR -c Rcpp_init.cpp -o Rcpp_init.o
/usr/local/bin/gcc-7 -I"/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/include" -DNDEBUG -I../inst/include/ -O2 -DFASTR -DNO_GNUR -fPIC -O2 -DFASTR -DNO_GNUR -c api.cpp -o api.o
/usr/local/bin/gcc-7 -I"/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/include" -DNDEBUG -I../inst/include/ -O2 -DFASTR -DNO_GNUR -fPIC -O2 -DFASTR -DNO_GNUR -c attributes.cpp -o attributes.o
/usr/local/bin/gcc-7 -I"/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/include" -DNDEBUG -I../inst/include/ -O2 -DFASTR -DNO_GNUR -fPIC -O2 -DFASTR -DNO_GNUR -c barrier.cpp -o barrier.o
/usr/local/bin/gcc-7 -Wl,-rpath,/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/lib/,-rpath,/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/../llvm/native/lib -L/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/lib -undefined dynamic_lookup -L/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/../llvm/native/lib -lf2c -dynamiclib -Wl,-headerpad_max_install_names -single_module -multiply_defined suppress -lR -Wl,-rpath,/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/lib/,-rpath,/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/../llvm/native/lib -L/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/lib -L/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/../llvm/native/lib -lf2c -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o
installing to /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
com.oracle.truffle.r.runtime.ffi.DLL$DLLException: unable to load shared object '/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so'
dlopen(/Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so, 6): Symbol not found: __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
Referenced from: /Users/admin/tools/maszyny-jvm/graalvm-ce-java8-20.0.0/Contents/Home/jre/languages/R/library/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
Expected in: flat namespace