cmake can't find java, but it's installed
If you are using the linux os then you have to set the java home like export
JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35
export PATH=$JAVA_HOME/bin:$PATH
CMake could not find JNI
As the CMake version bundled with Android tries to tell you, it can't find the JNI package because some parts were missing:
missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH
Checking the documentation for FindJNI (https://cmake.org/cmake/help/latest/module/FindJNI.html) these variables are set to the locations of libraries and headers not shipped with the Android version of JNI (to little surprise, Android does not included the AWT library for instance).
When running find_package(JNI REQUIRED)
, the FindJNI code checks if these variables are set and if not, issues an error.
A workaround is to set these variables yourself, before calling find_package
:
# We are only interested in finding jni.h: we do not care about extended JVM
# functionality or the AWT library.
set(JAVA_AWT_LIBRARY NotNeeded)
set(JAVA_JVM_LIBRARY NotNeeded)
set(JAVA_INCLUDE_PATH2 NotNeeded)
set(JAVA_AWT_INCLUDE_PATH NotNeeded)
find_package(JNI REQUIRED)
Be aware though, that your code will only be able to use jni.h and its functionality: if it tries to access any other part of the JNI package it will fail (probably at compile time) because essentially, you have tricked CMake into thinking that the entire package was found, when in reality only a part of it exists in the Android setup.
CMake cannot find Java on Linux Could NOT find Java (missing: Java_JAVAH_EXECUTABLE)
It looks like cmake is looking for javah
not javac
. You're using Java 1.8, so you should have javah installed. (It has been removed in a later version, and instead of javah
you're supposed to use javac -h
)
Make sure cmake can find the javah tool by setting JAVA_HOME so that it points at the Java 8 installation directory (typically under /usr/lib/jvm on a Linux system)
C++/CMake can't find libxml++
You may should add this line to your CMakeLists.txt :
include_directories("/usr/include/libxml++2.6/")
( or use any macro to achieve to this result )
then in your main :
#include <iostream>
#include <libxml++/libxml++.h> // <= like this
int main() {
std::cout << "hello" << std::endl;
}
Another way to do :
If it do not fix your problem you can also try to go to the libxml++ page : https://developer.gnome.org/libxml++-tutorial/stable/chapter-introduction.html .
Here you have a link to download libxml++.
Then you just have to follow the instruction in the file call INSTALL, and add the include directory with :
include_directories("<your-path/libxml++2.6>")
and add a new library path for your compilator when it search lib with
link_directories("<your-other-path>/lib")
Hoping it help you
cmake for OpenCV doesn't detect jdk
I solved it. Cmake for opencv needs ANT, but I didn't have it. For now cmake can make opencv with java support.
Related Topics
Iso 8601 String to Date/Time Object in Android
How to Get Unique Random Product in Node Firebase
How Set Background Drawable Programmatically in Android
Service Discovery Failed Exception Using Bluetooth on Android
Sqlite in Android How to Update a Specific Row
How to Add a Textview to Linearlayout in Android
Recyclerview Horizontal Scrolling to Left
Image Encryption/Decryption Using Aes256 Symmetric Block Ciphers
How to Convert a Color Integer to a Hex String in Android
Error:(23, 17) Failed to Resolve: Junit:Junit:4.12
Problems with Java3D Lib Configuration
Java Exec() Does Not Return Expected Result of Pipes' Connected Commands
How to Know Whether Enough Memory Is Free to Deploy a New Application on a Linux MAChine
Ssl Handshake Alert: Unrecognized_Name Error Since Upgrade to Java 1.7.0
Which Operating Systems Support Native (Inotify-Like) File Watching in Java