Compiling Android JNI for OpenCV on Mac OSX - java

Bear with me - this is a long description, but I wanted to include all details. I'm trying use android NDK and JNI for building OpenCV Android apps.
I'm following this tutorial to get everything installed:
http://www.stanford.edu/class/ee368/Android/Tutorial-2-OpenCV-for-Android-Setup-Macintosh-API8.pdf
The following installed just fine:
/usr/bin/g++
/usr/local/bin/swig
/usr/bin/cmake
/usr/bin/make
/Developer/pcre-8.32/
Contents of my .bashrc file:
export NDK=/Users/Me/Code/Android/android-ndk-r4-crystax
export SDK=/Users/Me/Code/Android/adt-bundle-mac-x86_64-20130219/
export OPCV=/Users/Me/Code/OpenCV/opencv
export PATH=$NDK:$SDK/tools:$SDK/platform-tools:$PATH
export NDK_ROOT=$NDK
Making OpenCV libraries went just fine.
Due to complaint in using make, I had to make a small edit in /Users/Me/Code/OpenCV/opencv/android/android-jni/local.env.mk which looked like so:
#ANDROID_NDK_ROOT=$(HOME)/android-ndk-r4-crystax
ANDROID_NDK_ROOT=/Users/Me/Code/Android/android-ndk-r4-crystax
Then upon trying again to make in the android-jni, directory, disaster struck:
/Users/Me/Code/Android/android-ndk-r4-crystax/ndk-build OPENCV_CONFIG=../build/android-opencv.mk \
PROJECT_PATH= ARM_TARGETS="armeabi armeabi-v7a" V=
Gdbserver : [arm-eabi-4.4.0] /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi/gdbserver
Gdbsetup : /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi/gdb.setup
Gdbsetup : + source directory /Users/Me/Code/OpenCV/opencv/android/android-jni/jni
Gdbserver : [arm-eabi-4.4.0] /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi-v7a/gdbserver
Gdbsetup : /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi-v7a/gdb.setup
Gdbsetup : + source directory /Users/Me/Code/OpenCV/opencv/android/android-jni/jni
SharedLibrary : libandroid-opencv.so
/Users/Me/Code/Android/android-ndk-r4-crystax/build/prebuilt/darwin-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: cannot find -lopencv_calib3d
collect2: ld returned 1 exit status
make[1]: *** [/Users/Me/Code/OpenCV/opencv/android/android-jni/obj/local/armeabi/libandroid-opencv.so] Error 1
make: *** [libs/armeabi-v7a/libandroid-opencv.so] Error 2
I thought perhaps this was a pkg-config error, but that appears to be set up as well, though in my old install of OpenCV. Below is the output of pkg-config --cflags --libs opencv:
-I/usr/include/opencv /usr/lib/libopencv_calib3d.dylib /usr/lib/libopencv_contrib.dylib /usr/lib/libopencv_core.dylib /usr/lib/libopencv_features2d.dylib /usr/lib/libopencv_flann.dylib /usr/lib/libopencv_gpu.dylib /usr/lib/libopencv_highgui.dylib /usr/lib/libopencv_imgproc.dylib /usr/lib/libopencv_legacy.dylib /usr/lib/libopencv_ml.dylib /usr/lib/libopencv_nonfree.dylib /usr/lib/libopencv_objdetect.dylib /usr/lib/libopencv_photo.dylib /usr/lib/libopencv_stitching.dylib /usr/lib/libopencv_ts.dylib /usr/lib/libopencv_video.dylib /usr/lib/libopencv_videostab.dylib
The install built by this particular tutorial has placed an opencv.pc file at this location:
/Users/Me/Code/OpenCV/opencv/build/unix-install
BUT Running the below and trying make again doesn't fix the problem:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/Users/Me/Code/OpenCV/opencv/build/unix-install
I can't figure out what is wrong. I've been battling with this problem for about a month on and off, and finally needed some outside opinions. Any ideas?

Error message says
cannot find -lopencv_calib3d collect2: ld returned 1 exit status
It means linker can't find opencv_calib3d library. It may have name libopencv_calib3d.a or libopencv_calib3d.so. So you need find one of them and add path to this file to your LD_LIBRARY_PATH env variable.
I mean if let's say folder /Users/Me/Code/OpenCV/opencv/lib contains libopencv_calib3d.so then you need execute something like following before make:
export LD_LIBRARY_PATH=/Users/Me/Code/OpenCV/opencv/lib:$LD_LIBRARY_PATH

Try the official OpenCV4Android tutorials at http://docs.opencv.org/trunk/doc/tutorials/introduction/android_binary_package/android_dev_intro.html

Related

Getting Error: Could not find or load main class org.apache.axis2.transport.SimpleAxis2Server

I am new to Axis , I am trying to start Axis2 as a Standalone Server using the Standard Binary Distribution package in Linux. I went through this guide: https://axis.apache.org/axis2/java/core/docs/installationguide.html
I have downloaded and unpacked the distribution in it's own directory and i have also set environment variables AXIS2_HOME and JAVA_HOME as follows :
export AXIS2_HOME=/opt/axis2-1.8.2
echo $AXIS2_HOME returns
/opt/axis2-1.8.2
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
echo $JAVA_HOME returns
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
When trying to run axis2server.sh which is essentially the script to start the server I get the following prompts :
user#serverFoo/opt/axis2-1.8.2/bin$ ./axis2server.sh
Using AXIS2_HOME: /opt/axis2-1.8.2
Using JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
Error: Could not find or load main class org.apache.axis2.transport.SimpleAxis2Server
Coming from a JAVA background I understand that it can't find or load the server class, although I can't find any resources in the web pointing to the specific error .
EDIT : I have also added CLASSPATH variable pointing to the AXIS2_HOME/lib directory i.e
export CLASSPATH=/opt/axis2-1.8.2/lib/*.jar but still the same .
Any ideas would be welcome.
Thanks

Vim YouCompleteMe Java setup

I'm trying to set up Java autocompletion for Vim using the YouCompleteMe plugin. I ran the install script and got the following message saying that I need to set an option called java_binary_path:
$ python3 install.py --java-completer --clang-completer
Generating ycmd build configuration...OK
Compiling ycmd target: ycm_core...OK
Building regex module...OK
Building watchdog module...OK
Installing jdt.ls for Java support...
*** WARNING ***: jdt.ls requires Java 17. You must set the option java_binary_path to point to a working java 17.
OK
I tried setting this in my ~/.vimrc file as follows, but now I'm getting the error E518: Unknown option: java_binary_path=/usr/local/opt/openjdk#17/bin/java:
set java_binary_path=/usr/local/opt/openjdk#17/bin/java
Does anyone know how to set this option?

Java error while running maxent in biomod2

I am running maxent from R, in the package biomod2 and the following error appeared. I do not come from a technical background and wasn't sure why is this error happening. Is it a memory problem or someone said the java path is not set. But I followed the instructions to set maxent to run in R and also downloaded Java Platform, Standard Edition Development Kit and set a path for it as explained in this pdf: http://modata.ceoe.udel.edu/dev/dhaulsee/class_rcode/r_pkgmanuals/MAXENT4R_directions.pdf
I would be really grateful if you could help me understand this problem and any solution to it.
Thanks a lot
Error in file(file, "rt") : cannot open the connection
In addition: Warning messages:
1: running command 'java' had status 1
2: running command 'java -mx512m -jar E:\bioclim_2.5min\model/maxent.jar environmentallayers
="rainfed/models/1432733200/m_47203134/Back_swd.csv"
samplesfile="rainfed/models/1432733200/m_47203134/Sp_swd.csv"
projectionlayers="rainfed/models/1432733200/m_47203134/Predictions/Pred_swd.csv"
outputdirectory="rainfed/models/1432733200/rainfed_PA1_Full_MAXENT_outputs"
outputformat=logistic redoifexists visible=FALSE linear=TRUE quadratic=TRUE
product=TRUE threshold=TRUE hinge=TRUE lq2lqptthreshold=80 l2lqthreshold=10
hingethreshold=15 beta_threshold=-1 beta_categorical=-1 beta_lqp=-1
beta_hinge=-1 defaultprevalence=0.5 autorun nowarnings notooltips
noaddsamplestobackground' had status 1
3: In file(file, "rt") :
cannot open file 'rainfed/models/1432733200/rainfed_PA1_Full_MAXENT_outputs/rainfed_PA1_
Full_Pred_swd.csv': No such file or directory
I've just manage to solve this problem - it is a problem with the file path specified. For me, I had a space in one of the folder names which was not accepted in the path to the maxent.jar file. From looking at your error, it looks like it might be the two backslashes.
E:\bioclim_2.5min\model/maxent.jar
should probably read
E:/bioclim_2.5min/model/maxent.jar

Can't build cordova projects

I have a problem with setting up the work environment for Cordova on Windows 7 for Android. I use NetBeans 8 and followed this guide: Link Here
New project -> Cordova -> Hello World Template.
Whenever I try to build a Cordova project (in NetBeans) I get this message:
BUILD FAILED
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml
Total time: 0 seconds
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\node_modules\q\q.js:126
throw e;
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Command finished with error code 8: C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\cordova\run.bat --emulator
C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\nbproject\build.xml:272: exec returned: 1
BUILD FAILED (total time: 47 seconds)
I have googled it for hours but can't seem to find a solution. Some people get some of the same errors(not exact, but similar), but the solutions did not work for me. One issue was regarding Java 8 and ant versions beneath 1.9.0 (I use Node 0.10.26, java 1.7.0_25, cordova 3.5.0-0.2.4 and ant 1.9.4). I also tried to create a new project with the console (CMD), but it gives the exact same error when I build. It's no problem to create the project, nor adding Android as a platform, the problem is building the project. I think the environment variables are set correctly since the java, node, ant and cordova commands work fine in cmd/powershell, and the check_reqs.bat said that the environment was fine.
It's this line that creates the error: <import file="${sdk.dir}/tools/ant/build.xml" />. This is the rest of the message: Cannot find C:\Users\Administrator\SkyDrive\Skolegang\Dataingeniør\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Administrator\Documents\NetBeansProjects\HTML5Application2\platforms\android\build.xml.
Here is the error I get in the command window (not using NetBeans):
PS C:\Users\Administrator\Desktop\test\fakeApp> cordova build android
Running command: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat
Buildfile: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml
BUILD FAILED
C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\build.xml:90: Cannot find C:\Users\Administrator\SkyDrive\
Skolegang\Dataingeni├©r\Android\adt-bundle-windows-x86_64-20130729\sdk\tools\ant\build.xml imported from C:\Users\Admini
strator\Desktop\test\fakeApp\platforms\android\build.xml
Total time: 0 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\Administrator\Desktop\test\fakeApp\platforms\androi
d\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\Users\Administrator\Desktop\test\fakeApp\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\s
rc\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
I thought maybe it was a path issue since I have a special letter in the path were the NetBeansProjects are stored (and it's pretty long too), but creating a test directory at C:\ and creating the project with the command window gave the same error. I'm new at Cordova so I'm sure there's an easy solution, thanks in advance.
I solved it, though I tried to create a cordova project outside the OneDrive folder I did not think of the SDK path (which also were stored in OneDrive). By moving the SDK files to C: (the path could probably not contain the special letter 'ø') and changing the path of the environment variables (and the SDK path in NetBeans) it now runs perfectly.

Monodevelop + IKVM : Java build error ("Error: invalid path: *.class")

I am using the monodevelop Java plugin to compile a simple (hello world) Java project. The project is created fine, but when I try to build it I get the following error:
"Error: invalid path: *.class"
The command that triggers the error is as follows:
ikvmc -recurse:*.class -assembly:jTest -target:exe -debug -srcpath:/home/bob/src/jTest/jTest -r:mscorlib
Any idea what's going wrong, and how to fix this?
P.s. Please do not say "Mono is not for Java. Use (insert different Java IDE here) instead"
Thank you!
I think .\*.class sould be run better. There must at minimum one slash in the path.

Categories

Resources