cmake find_package(JNI) not work in Ubuntu 12.04 amd64 - cmake

I am using cmake 2.8.7 on Ubuntu 12.04 amd64. The installed OpenJDK JRE components in my system are listed below :
$ sudo dpkg --list | grep jdk
openjdk-6-jre 6b27-1.12.5-0ubuntu0.12.04.1 OpenJDK Java runtime, using Hotspot JIT
openjdk-6-jre-headless 6b27-1.12.5-0ubuntu0.12.04.1 OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-6-jre-lib 6b27-1.12.5-0ubuntu0.12.04.1 OpenJDK Java runtime (architecture independent libraries)
However, I am not using the OpenJDK JRE components. I have manually installed Oracle Java 7 JDK
in "/usr/lib/jvm/jdk1.7.0_25" and have used "update-alternatives" to point "java" to my installed Oracle Java 7 JDK. I have not set any "JAVA_HOME", "JAVA_BIN", "CLASSPATH" environment variables and the manually installed Oracle Java 7 JDK seems work OK in Eclipse 4.3.
The problem is that when I use "find_package(JNI)" in cmake and use the "message()" function to show the JNI variables, I have the following result :
Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
JNI_FOUND = FALSE
JNI_LIBRARIES = /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjawt.so;/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
JAVA_INCLUDE_PATH = JAVA_INCLUDE_PATH-NOTFOUND
JAVA_INCLUDE_PATH2 = JAVA_INCLUDE_PATH2-NOTFOUND
JAVA_AWT_INCLUDE_PATH = JAVA_AWT_INCLUDE_PATH-NOTFOUND
JAVA_JVM_LIBRARY = /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
JAVA_AWT_LIBRARY = /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjawt.so
JNI_INCLUDE_DIRS = JAVA_INCLUDE_PATH-NOTFOUND;JAVA_INCLUDE_PATH2-NOTFOUND;JAVA_AWT_INCLUDE_PATH-NOTFOUND
The "find_package(JNI)" seems could find some of the Java components related to the OpenJDK JRE and could not find my current Oracle Java 7 JDK components pointed by "update-alternatives".
I want to know that is there any bug in the "FindJNI.cmake" file and what I have missed in the Oracle Java 7 JDK setup so that cmake "find_package(JNI)" could work properly.
Thanks for any suggestion.

You can manually modify FindJNI.cmake to help it find your installed JDK.
See this gist:
https://gist.github.com/emchristiansen/6845954
It's a shame this script hasn't been updated, but maybe not a surprise, given that CMake is such a disaster.
EDIT: A more straightforward solution is to set JAVA_HOME properly.
With OpenJDK 7 installed, I set it with:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

If you have oracle jdk 7 installed on your system, as was my case, you might run into the issues while building opencv. For resolving those issues, I had to edit, /usr/share/cmake-2.8/Modules/FindJNI.cmake file. In this file, I commented out the lines with references to openjdk and default and added references of oracle jdk 7 as shown below.
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
${_JAVA_HOME}/jre/lib/{libarch}
${_JAVA_HOME}/jre/lib
${_JAVA_HOME}/lib
${_JAVA_HOME}
/usr/lib
/usr/local/lib
/usr/lib/jvm/java/lib
/usr/lib/java/jre/lib/{libarch}
/usr/lib/jvm/jre/lib/{libarch}
/usr/local/lib/java/jre/lib/{libarch}
/usr/local/share/java/jre/lib/{libarch}
/usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
/usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
/opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
/usr/lib/jvm/java-6-sun/jre/lib/{libarch}
/usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex
#/usr/lib/jvm/java-6-openjdk/jre/lib/{libarch} # Commented by Atul
#/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch} # fedora
# Debian specific paths for default JVM
#/usr/lib/jvm/default-java/jre/lib/{libarch} # Commented by Atul
#/usr/lib/jvm/default-java/jre/lib # Commented by Atul
#/usr/lib/jvm/default-java/lib # Commented by Atul
# OpenBSD specific paths for default JVM
/usr/local/jdk-1.7.0/jre/lib/{libarch}
/usr/local/jre-1.7.0/lib/{libarch}
/usr/local/jdk-1.6.0/jre/lib/{libarch}
/usr/local/jre-1.6.0/lib/{libarch}
/usr/lib/jvm/java-7-oracle/jre/lib/{libarch} # This is added Atul
)
and in the section where the script looks for include library...
set(JAVA_AWT_INCLUDE_DIRECTORIES
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
${_JAVA_HOME}/include
/usr/include
/usr/local/include
/usr/lib/java/include
/usr/local/lib/java/include
/usr/lib/jvm/java/include
/usr/lib/jvm/java-6-sun/include
/usr/lib/jvm/java-1.5.0-sun/include
/usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
#/usr/lib/jvm/java-6-openjdk/include
/usr/local/share/java/include
/usr/lib/j2sdk1.4-sun/include
/usr/lib/j2sdk1.5-sun/include
/opt/sun-jdk-1.5.0.04/include
# Debian specific path for default JVM
#/usr/lib/jvm/default-java/include
# OpenBSD specific path for default JVM
/usr/local/jdk-1.7.0/include
/usr/local/jdk-1.6.0/include
/usr/lib/jvm/java-7-oracle/include
)
Then I followed exact instructions to build the openCV for android.
I had to comment out openjdk and default related lines, since they were conflicting with oracle installations.

Related

Pentaho Data Integration not starting on new Mac M1

I have an issue when I try running Pentaho Data Integration on Mac bigSur (M1).
issue code in below:
I'm sorry, this Mac platform [arm64] is not yet supported! Please try starting using 'Data Integration 32-bit' or 'Data Integration 64-bit' as appropriate.
java version
> java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
can anyone help me with this issue?
Thanks
Try this guide from reddit
Guide:
Here is how you can force the shell to run in Intel mode so that you
can continue working in this little command-line Rosetta Island while
waiting for native ARM64 support.
Open the Terminal app.
Open the Terminal app’s Preferences.
Click on the Profiles tab.
Select a profile, click on the ellipsis at the bottom of the profile list and then select Duplicate Profile.
Click on the new profile and give it a good name. I named mine as “Rosetta Shell”.
Also in the new profile, click on the Window tab. In the Title, put a name to indicate that this is for running Intel-based apps.I put “Terminal (Intel)” on mine.
Click on the Shell tab and use the following as its Run Command to force the shell run under Rosetta: env /usr/bin/arch -x86_64 /bin/zsh --login
Untick the Run inside shell checkbox. Clearing the checkbox would prevent running the shell twice, which could bloat your environment variables since ~/.zshrc gets run twice.
Optionally set this profile as the Default.
This is the first step. After that you have to replace the swt.jar in the data-integration Folder /path_to_your_data-integration/libswt/osx64/
Otherwise it won't start.
You can download the jar here
Important!: You don't have to rename this file, but you have to remove the original swt.jar .
I've just want to add that you need to have an x86 Java version installed for Tufan Atak solution to work.
So if you've installed an M1 compat Java version and you try to start spoon with that it will throw the next error:
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cocoa-4944r26 in java.library.path
no swt-cocoa in java.library.path
no swt in java.library.path
Can't load library: /<user-home-path>/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib
Can't load library: /<user-home-path>/.swt/lib/macosx/aarch64/libswt-cocoa.jnilib
Can't load library: /<user-home-path>/.swt/lib/macosx/aarch64/libswt.jnilib
/<user-home-path>/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib: dlopen(/<user-home-path>/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib, 0x0001): tried: '/<user-home-path>/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:348)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:257)
at org.eclipse.swt.internal.C.<clinit>(C.java:19)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:107)
at org.pentaho.di.ui.core.widget.OsHelper.setAppName(OsHelper.java:106)
at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:652)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:92)
So you need to install Java again from the same intel terminal profile so an x86 version is installed.
You can use SDK Man and after that you can execute this command (for java 8 temurin):
> sdk install java 8.0.345-tem
.
.
.
> Do you want java 8.0.345-tem to be set as default? (Y/n): n
The n answer is because you don't wanna run every other java program with the x86 version.
After that you can tell SDK Man to use this new version for this terminal shell
> sdk use java 8.0.345-tem
then just verify the current version is the one you've just indicated sdk man to use:
> java -version
you should see something like this:
openjdk version "1.8.0_345"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_345-b01)
OpenJDK 64-Bit Server VM (Temurin)(build 25.345-b01, mixed mode)
After that you can finally start spoon
> ./spoon.sh

distro 'rhel7.2' does not exist in our dictionary

While installing a kvm via virt-install I have used following attribute os_variant=rhel7.2. While installing I am getting following error :
distro 'rhel7.2' does not exist in our dictionary
When I do uname -r I am getting output as
3.10.0-327.el7.x86_64
It is a RHEL KVM host.
Running osinfo-query os|grep 'Red Hat Enterprise Linux 7.2' returns following:
rhel7.1 | Red Hat Enterprise Linux 7.2 | 7.2 | http://redhat.com/rhel/7.2
What can be solution to this problem?
You could create a custom config file to define a RHEL-7.2 distro, but it is honestly not that important from virt-install's POV. The distro is used to lookup the optimized drivers to use for disk & network primarily. Just using the 'rhel7.1' distro type when installing 'rhel-7.2' will work just fine from this POV.
virt-install get's it's os information out of osinfo-db
If your os does not ship a recent version of osinfo-db you can manually download it from https://releases.pagure.org/libosinfo/ and import it.
e.g.
wget https://releases.pagure.org/libosinfo/osinfo-db-20200325.tar.xz
osinfo-db-import -v osinfo-db-20200325.tar.xz
-v will display all imported os'es, I believe your choice has to match one of the xml files in this list.

Undefined symbol error in Centos compile

I have run into an interesting problem. I am compiling my application code and was using ace library(version 6_1_1) on my centos 6 machine. Everything worked fine. When i look at the symbols of the ace library compiled on centos 6 machine, it looks like this:
bash-4.1$ nm ace/libACE.so.6.1.1 | grep handle_sig 000f9430 T
_ZN15ACE_Sig_Adapter13handle_signalEiP7siginfoP8ucontext 000b84d0 T _ZN17ACE_Event_Handler13handle_signalEiP7siginfoP8ucontext 00079f10 T _ZN18ACE_Service_Config13handle_signalEiP7siginfoP8ucontext 000f26d0 T _ZN19ACE_Process_Manager13handle_signalEiP7siginfoP8ucontext 0007ee70 T _ZN19ACE_Service_Manager13handle_signalEiP7siginfoP8ucontext
000cf920 T
_ZN20ACE_MMAP_Memory_Pool13handle_signalEiP7siginfoP8ucontext 000f8b80 T _ZN22ACE_Shared_Memory_Pool13handle_signalEiP7siginfoP8ucontext
bash-4.1$
But when i compile the same project on centos 7 machine, the symbols change:
bash# nm ace/6_1_1/ace/libACE.so.6.1.1 | grep handle_sig 000fa090 T
_ZN15ACE_Sig_Adapter13handle_signalEiP9siginfo_tP8ucontext 000b9570 T
_ZN17ACE_Event_Handler13handle_signalEiP9siginfo_tP8ucontext 0007e070 T
_ZN18ACE_Service_Config13handle_signalEiP9siginfo_tP8ucontext 000f3500 T
_ZN19ACE_Process_Manager13handle_signalEiP9siginfo_tP8ucontext 00081cb0 T
_ZN19ACE_Service_Manager13handle_signalEiP9siginfo_tP8ucontext 000d1990 T
_ZN20ACE_MMAP_Memory_Pool13handle_signalEiP9siginfo_tP8ucontext 000f93d0 T
_ZN22ACE_Shared_Memory_Pool13handle_signalEiP9siginfo_tP8ucontext bash#
Notice that there is an extra _t in siginfo. So, my application which links this library fails to launch during run time giving me that error:
symbol "_ZN17ACE_Event_Handler13handle_signalEiP9siginfo_tP8ucontext"
not found
Another interesting point to note is that if i copy the compiled ace library from my centos 6 box into centos 7 box, my application works fine.
I am lost on how to fix this issue. Any help in this regards will be appreciated!
But when i compile the same project on centos 7 machine, the symbols change:
Probably Glibc on Centos 7 has changed one of the types in public headers which caused mangler to emit different symbols:
$ echo _ZN15ACE_Sig_Adapter13handle_signalEiP7siginfoP8ucontext | c++filt
ACE_Sig_Adapter::handle_signal(int, siginfo*, ucontext*)
$ echo _ZN15ACE_Sig_Adapter13handle_signalEiP9siginfo_tP8ucontext | c++filt
ACE_Sig_Adapter::handle_signal(int, siginfo_t*, ucontext*)
Notice that new method now uses siginfo_t rather than siginfo (you'll see hundreds of complaints if you google for "siginfo_t vs siginfo").
Another interesting point to note is that if i copy the compiled ace
library from my centos 6 box into centos 7 box, my application works fine.
That's backward compatibility - you can (usually) run apps linked on older version of distro on it's newer versions.
On the contrary, forward compatibility (in your case - linking old application against new library) is not guaranteed.
I am lost on how to fix this issue.
If you are only interested in new CentOS - rebuild all your code. If you want to run on older versions - build on the oldest and distribute that.

Sat4j Remote Control window doesn't open

What happens:
I execute the following command.
java -jar sat4j-sat.jar -remote
No window opens, and I get a console output same as without the -remote flag, which begins:
c SAT4J: a SATisfiability library for Java (c) 2004-2013 Artois (...)
c This is free software under the dual EPL/GNU LGPL licenses.
c See www.sat4j.org for details.
c version 2.3.4.v20130419
c java.runtime.name OpenJDK Runtime Environment
c java.vm.name OpenJDK Client VM
c java.vm.version 24.65-b04
c java.vm.vendor Oracle Corporation
c sun.arch.data.model 32
c java.version 1.7.0_65
c os.name Linux
c os.version 3.2.0-4-686-pae
(...)
What is expected:
From readme.txt:
To run sat4j with on the fly configuration:
java -jar sat4j-sat.jar -remote
These instructions should open a java window named Remote Control. We
assume that the 1.5 version of the java command is in your path. If
it isn’t, then you should either specify the complete path to the java
command or update your PATH environment variable as described in the
installation instructions for the Java 2 SDK.
Other details
I have tried multiple versions of the library, up to 2.3.4.
My system is Debian 7 with Gnome 2.
My default Java installation is OpenJDK 1.7.0_65.
My secondary Java installation is Oracle Java 1.8.0_45 (with the same issue).
Gnuplot 4.6 is installed.
My first machine has a 32 bit dual core CPU with 2GB of RAM.
My second machine has a 64 bit quad core CPU with 8GB of RAM with nearly identical software.
Question
Has anyone used SAT4J's remote control feature? What is the problem with my method?
Update
On another machine (64 bit Debian 7) the window opens. After start dat files are created, but plotting does not start.
Update 2
I ran the generated instance.dimacs-gnuplot.gnuplot file manually from a gnuplot terminal, and I got the message unknown or ambiguous terminal type for the x11 type. I installed the gnuplot-x11 package, and now it works on the workplace machine: I can see the diagrams (wow!). Unfortunately on my home machines the Remote Control window still doesn't open.
The -remote parameter is used to display the remote control, i.e. to setup the various parameters of the solver.
If you want to always monitor what the solver is doing, you need to use in conjunction the -r parameter.
So the complete command line should be:
java -jar sat4j-sat.jar -r -remote file.cnf
You can get a fresh snapshot of Sat4j Sat on our continuous integration server:
http://bamboo.ow2.org/browse/SAT4J-DEF2-41/artifact/JOB1/nightly_build/
This might solve the issue you met with the 2.3.4 release.
Cheers,
Daniel

DllNotFoundException libpjsipDll Mono

I've a problem to execute a program with Mono in the terminal, (mono program.exe). An error appears : "System.DllNotFoundException : libpjsipDll.so "
however my library exists and I've setted my 2 environment variables : LD_LIBRARY_PATH and MONO_PATH in the directory where the file is.
I don't understand why this error occured ?
Anyone has an idea ?
I've :
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped (CPU architecture)
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),dynamically linked, not stripped (third-party lib)
I try MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll".
and I obtain an : undefined symbol : Pa_GetErrorText
I try to install PortAudio but I doesn't work always :-(
Thanks in advance.
Narglix
First of all, make sure that the letter casing is correct in that the library you are calling and the assembly on disk have the same case. Linux is picky about it.
I assume that you are using P/Invoke DLLImport? What is the actual code you are using here? You library (libpjsipDll.so) is not managed code of course.
Is not a problem about loading, is a problem about another dependency dll, just run this code and make sure the libpjsipDll.so is where the callingApp.exe is executing.
//I tried this in ubuntu $ sudo apt-get install libssl0.9.8:i386
I discovered that running my App like this:
$ MONO_LOG_LEVEL=debug mono MyApp.exe
Here is my question, where you can find adittional info:
MonoDevelop and libpjsipDll.so library on Ubuntu. System.DllNotFoundException