rJava installation ld:library not found for -lpcre2-8 - c++

Trying to use rJava and have it use java version 11.
Currently it uses a previous installation I had of version 17.
When I run R CMD javareconf most of the settings look right.
Java interpreter : /Users/adam/.jenv/shims/java
Java version : 11.0.13
Java home path : /Library/Java/JavaVirtualMachines/zulu11.52.13-ca-jdk11.0.13-macosx_aarch64/zulu-11.jdk/Contents/Home
Java compiler : /Users/adam/.jenv/shims/javac
Java headers gen.: /Users/adam/.jenv/shims/javah
Java archive tool: /Users/adam/.jenv/shims/jar
...
and yet when I call rJava::.jcall("java.lang.System","S","getProperty","java.version") I still get version 17.
Consequently I've tried re-installing rJava from source. When I do this the installation recognizes Java 11 as the "default" java installation to use, but I run into a problem with my cpp compiler, as I see the error
ld: library not found for -lpcre2-8
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
when I run install.packages("rJava",type="source").
Other questions(1,2,3) have similar issues but my attempts to replicate the installation of the linker libraries, libpcre2-dev libbz2-dev zlib1g-dev as recommended to an ubuntu user did not work for me – I have not been able to find out how I might install the library as a Mac user . Furthermore, I'm not exactly sure if the "linkages" are setup appropriately in such cases.
Question
How/Where can I find and install the -lpcre2-8 package for the mac version specified below and ensure that the appropriate linkages are in place for the rJava compilation?
Details
I'm working on a Mac OS v12.0.1 (M1 chip), R v.4.1.2 using Rstudio v1.4.1717 to run R.

First, re-compiling won't have any effect. The Java version used on macOS is governed by:
the JAVA_HOME environment variable
system Java selection (see /usr/libexec/java_home)
Normally, JAVA_HOME is not set, so your macOS system setting is used. You can see your installed Java versions with /usr/libexec/java_home -V including which is selected:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
17, x86_64: "Java SE 17" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
1.8.0_252, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
If you want to change the default, you can set JAVA_HOME to the preferred value. For example:
## use Java 1.8
$ JAVA_HOME=`/usr/libexec/java_home -v 1.8` Rscript -e \
'print(rJava::J("java.lang.System")$getProperty("java.version"))'
[1] "1.8.0_252"
## use Java 17
$ JAVA_HOME=`/usr/libexec/java_home -v 17` Rscript -e \
'print(rJava::J("java.lang.System")$getProperty("java.version"))'
[1] "17"
Second, if you want to re-compile rJava, you will need all libraries used to build R. For CRAN R build those are provided in https://mac.r-project.org/bin/, but I would not recommend going there unless you want to modify rJava. You can make your life easier by not compiling JRI (embedding R in Java) support, i.e. adding --disable-jri since it's that part which requires the libraries used by R. Just the rJava package itself doesn't need it.
Finally, it's usually a lot faster to ask on the support page rJava Discussion.

Related

Problem with Ocaml and make: "Error: the file ____.cmxa is not a compilation unit description"

I'm running make in the top level of the UniMath directory and make keeps returning errors. I'm working on fedora 35 and I'm using Ocaml version 4.11.2.
Here is a print out of the errors
make[2]: Entering directory '/home/rymndbkr/UniMath/sub/coq'
OCAMLBEST -o bin/coqdep_boot
File "_none_", line 1:
Error: tools/coqdep_boot.cmx is not a compilation unit description.
OCAMLBEST -o bin/ocamllibdep
File "_none_", line 1:
Error: tools/ocamllibdep.cmx is not a compilation unit description.
COQMKTOP -o bin/coqtop.opt
File "topbin/coqtop_bin.ml", line 11, characters 20-32:
11 | let drop_setup () = Mltop.remove ()
^^^^^^^^^^^^
Error: Unbound module Mltop
make[2]: *** [Makefile.build:422: bin/coqtop.opt] Error 2
make[2]: Leaving directory '/home/rymndbkr/UniMath/sub/coq'
make[1]: *** [Makefile.make:178: submake] Error 2
make[1]: Leaving directory '/home/rymndbkr/UniMath/sub/coq'
Makefile:76: .coq_makefile_output.conf: No such file or directory
make: *** [Makefile:247: sub/coq/bin/coq_makefile] Error 2
I'll describe the process I went through in hopes that it is reproducible. I was following the UniMath installation instructions on their github (https://github.com/UniMath/UniMath/blob/master/INSTALL.md). They did not have any installation instructions for fedora so I attempted to convert their Debian instructions. The main thing they wanted Debian users to do was run the command
sudo apt-get install build-essential git ocaml ocaml-nox ocaml-native-compilers camlp5 libgtk2.0 libgtksourceview2.0 liblablgtk-extras-ocaml-dev ocaml-findlib libnum-ocaml-dev emacs
To convert this, I made sure I had Ocaml version 4.11.2. I just followed the steps on Ocaml's site (https://ocaml.org/docs/install.html). There was a script which prompted me to modify ~/.bash_profile. I said yes. I also said yes when it prompted me to add a hook.
I also installed ocaml-num via the command dnf since this was required for later versions of ocaml.
I also installed #development-tools via dnf since another stack exchange post recommended it as the best fedora equivalent of build-essentials, the latter of which is part of the downloads for prepping a Debian computer for UniMath.
There are some things I did not mention that the UniMath site said to install to prep a Debian computer. I either had these things (or their equivalents installed) or could not figure out if they had equivalents.
I decided to just go ahead and try to finish the installation. I simply ran
git clone https://github.com/UniMath/UniMath
cd \UniMath
make BUILD_COQIDE=yes
It is on the last of these commands that the errors arose.
P.S. - Please let me know if there is information I should add to this question, or any way to improve it.
The error message not a compilation unit description is likely due to a mismatch between the Ocaml version that compiled the file and the one that is trying to read it.
You can use ocamlobjinfo to check that hypothesis.
A possible fix is to use make clean to reinitialize the state, and then rebuild it after ensuring that the environment is consistent with a call to eval $(opam env).

Apps cannot detect C++ poco even though I have installed it

I want to be able to make and run this particular library on my computer. Currently going through the INSTALL file. I am currently at the point:
After extracting the Poco (Complete Edition) source archive, the configure
script should be called with the following parameters:
./configure --omit=Crypto,Net,NetSSL_OpenSSL,Data/ODBC,Data/MySQL \
--no-tests --no-samples
This line avoids building the parts of Poco which are dependent on third-party
libraries, and are not required for openBliSSART.
You can also specify a prefix where Poco should be installed, but in most cases
you should leave the default /usr/local.
I can't seem to run the options, so I simply ran ./configure, this seemed to have worked till the point where I encountered:
checking for fftw_plan_dft_r2c_1d in -lfftw3... yes
checking for Poco (Enterprise)... no
configure: error: Need Poco Enterprise v1.3.6+!
But the fact is, that I have installed Poco already on the system through a brew install poco and downloaded the library from their source website and compiled it ground up. looking back at INSTALL:
Depending on where you have installed Poco, you may have to set the
LD_LIBRARY_PATH environment variable to contain the Poco "lib" directory,
or run the ldconfig tool. The following lines work with Ubuntu and openSUSE
($ indicates the shell prompt):
$ sudo sh -c 'echo <prefix>/lib > /etc/ld.so.conf.d/poco.conf'
$ sudo ldconfig
where <prefix> is the Poco install prefix (by default /usr/local).
Now when I do a simple sudo find / -name poco, I get:
/usr/local/var/homebrew/linked/poco
/usr/local/opt/poco
/usr/local/Cellar/poco
find: /private/var/db/ConfigurationProfiles/Store: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/SafariFamily: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.LaunchServices.dv: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.routined: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s4000069/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s4000069/0/com.apple.routined: Operation not permitted
/Users/sharanduggirala/Library/Logs/Homebrew/poco
/Users/sharanduggirala/Documents/of_v0.9.8_osx_release/libs/poco
/Users/sharanduggirala/Documents/of_v0.9.8_osx_release/scripts/apothecary/formulas/poco
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
Also, it looks like while building poco, I did a ./configure --static. Would this have affected my compilation? How do I link this library?
I have already used the command ./configure --with-poco-prefix=/usr/local/opt/poco which doesn't really change anything.
Notes relating to S.M.'s Answer
I tried this, but got the error:
brew install poco --with-static ⏎
==> Downloading https://pocoproject.org/releases/poco-1.9.0/poco-1.9.0-all.tar.gz
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: 028de410fc78d5f9b1ff400e93ec3d59b9e55a0cbbf0d8fec04636882b72ea45
Actual: 0387bf0f9d313e2311742e1ad0b64e07f2f3e76039eed20e3b9aa9951b88e187
Archive: /Users/sharanduggirala/Library/Caches/Homebrew/poco-1.9.0.tar.gz
To retry an incomplete download, remove the file above.
I also tried:
./configure --static ⏎
configure: error: unrecognized option: `--static'
Try `./configure --help' for more information
Do not install poco from sources. Use brew install poco. If you want the same like ./configure --static use brew install poco --with-static.

Installing OpenCV 3 in Homebrew using libstdc++

I am installing Caffe on Mac OS X 10.11 El Capitan, which somehow requires that I install OpenCV with libstdc++. To do so, I did "brew update opencv" and adding the following lines below "def install" as mentioned on the Caffe website (http://caffe.berkeleyvision.org/install_osx.html):
def install
# ADD THE FOLLOWING:
ENV.append "CXXFLAGS", "-stdlib=libstdc++"
ENV.append "CFLAGS", "-stdlib=libstdc++"
ENV.append "LDFLAGS", "-stdlib=libstdc++ -lstdc++"
# The following is necessary because libtool likes to strip LDFLAGS:
ENV["CXX"] = "/usr/bin/clang++ -stdlib=libstdc++"
...
However, when I go install it using "brew install --build-from-source -vd opencv", I get the following error:
cd /tmp/opencv-20170909-8122-1xa5qpl/opencv-3.3.0/build/modules/dnn &&
/usr/local/Cellar/cmake/3.9.2/bin/cmake -E cmake_symlink_library
../../lib/libopencv_dnn.3.3.0.dylib ../../lib/libopencv_dnn.3.3.dylib
../../lib/libopencv_dnn.dylib [ 59%] Built target opencv_dnn make: ***
[all] Error 2 /usr/local/Homebrew/Library/Homebrew/debrew.rb:11:in
`raise' BuildError: Failed executing: make
1. raise
2. ignore
3. backtrace
4. irb
5. shell Choose an action:
Anyone know how to solve this? Thank you in advance!
EDIT: Actually, I realized that my original opencv.rb file is producing the exact same problem. How do I fix/find an opencv.rb file that works?
It looks like he build you are going for in not compatible with the OS. If installing on Mac would suggest trying this method of implementation. It also uses homebrew but allows for a quick and simple implementation.

Protobuf 3.0.0-alpha-1 not compiling on windows

I'm trying to compile protobuf 3.0.0 alpha 1 on Windows using MinGW 4.9.2 & MSYS.
According to the instructions I'm supposed to:
./configure
make
make check
make install
I added --prefix=/c/path/to/mingw to configure (How to build Google's protobuf in Windows using MinGW?) but it didnt help.
It fails at make with the message:
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /home/Markus/protobuf-3.0.0-alpha-
1/missing aclocal-1.14 -I m4
/home/Markus/protobuf-3.0.0-alpha-1/missing: line 81: aclocal-1.14: command not
found
WARNING: 'aclocal-1.14' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127
I've tried installing Automake but it doesnt come with aclocal.
Also today at work i managed to get it working on the first try with a bare MinGW & MSYS.
It looks like you need to install autoconf (which is separate from automake, though they are often used together). You may also need to install libtool.

Trying to install OCaml 3.12.1 on Linux with Godi

I'm trying to install OCaml 3.12.1 on 64 bit Linux (Mint Linux which is essentially Ubuntu 11.04). I'm using the latest rocketboost (godi-rocketboost-20110717). I run ./bootstrap and after a while get the following (in bootstrap.log):
4287 ### Building godi-pcre
4288 ===> Cleaning for godi-pcre-6.2.2godi1
4289 => Checksum mismatch for pcre-ocaml-6.2.2.tar.gz.
4290 Make sure the Makefile and checksum file (/home/phil/godi-3.12.1/build/godi/ godi-pcre/distinfo)
4291 are up to date. If you want to override this check, type
4292 "godi_make NO_CHECKSUM=yes [other args]".
4293 Error: Exec error: File /home/phil/godi-3.12.1/build/godi/godi-pcre/./../../ mk/bsd.pkg.mk, line 1689: Command returned with non-zero exit code
4294 Error: Command fails with code 1: godi_console
Is this a package problem with pcre?
And how would I use the suggest "godi_make NO_CHECKSUM=yes [other args]" to fix this?
This has been fixed by the maintainer of the pcre-ocaml library. It should work fine now.