shayzalman / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Exception while compiling javacv on Raspberry PI #418

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compiling openCV 2.4.5 on Raspberry PI Debian Wheezy for Java
2. Download javacpp and javacv
3. mvn clean install javacpp works fine
4. mvn clean install javacv -> exception while compiling with cpp bindings

What is the expected output? 
At end of build process there should be a opencv.jar for linux-arm.
What do you see instead?
Exception because cmake doesn't find jni.h but JAVA_HOME is already set

What version of the product are you using? 
Using opencv 2.4.5 with javacv 0.7,javacpp 0.7

On what operating system?
OS: Linux raspberrypi 3.10.28+ #632 PREEMPT Tue Jan 28 18:42:43 GMT 2014 armv6l 
GNU/Linux 

Please provide any additional information below.
[INFO] --- maven-compiler-plugin:2.3:compile (default-compile) @ javacv ---
[INFO] Compiling 44 source files to /usr/opt/prj/javacv/target/classes
[INFO]
[INFO] --- exec-maven-plugin:1.2:exec (javacpp) @ javacv ---
Generating source file: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniThreadLocal.cpp
Source file not generated: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniThreadLocal.cpp
Generating source file: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jni.cpp
Source file not generated: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jni.cpp
Generating source file: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp
Compiling library file: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvk
ernels.so
g++ -I/usr/local/include/ 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp 
-march=armv7-a -mfloat-abi=softfp -mfpu               =vfpv3-d16 -mfpu=neon 
-ffast-math -Wl,-rpath,$ORIGIN/ -Wall -O3 -fPIC -shared -s -o 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cp               
p/linux-arm/libjnicvkernels.so -L/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ 
-lopencv_core
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp:28
:17: fatal error: jni.h: File or directory not found
compilation terminated.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:47.022s
[INFO] Finished at: Mon Feb 03 20:06:01 UTC 2014
[INFO] Final Memory: 12M/55M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec 
(javacpp) on project javacv: Command execution failed. Process exit             
  ed with an error: 1(Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Original issue reported on code.google.com by mifun...@gmx.de on 3 Feb 2014 at 8:36

GoogleCodeExporter commented 8 years ago
Where is `jni.h` file located on your system?

Original comment by samuel.a...@gmail.com on 5 Feb 2014 at 11:19

GoogleCodeExporter commented 8 years ago
Hi,

the jni.h is located at /usr/lib/jvm/jdk-7-oracle-armhf/include.
I just wonder why I don't see this path in the call of the g++-Compiler. 
There's only /usr/local/include. As said before JAVA_HOME is set with 
/usr/lib/jvm/jdk-7-oracle-armhf. Is there any possibility to configure the 
paths used by g++? I saw in other blogs that the path to Java installation is 
included in the call of the g++-Compiler.

Thanks in advance

Original comment by mifun...@gmx.de on 5 Feb 2014 at 7:14

GoogleCodeExporter commented 8 years ago
JavaCPP isn't using JAVA_HOME, because it's not usually set by default and we 
can get a path from the "java.home" system property anyway, so I'm guessing the 
problem is that you installed Oracle JDK, but you're actually using OpenJDK on 
the command line. If this is the case, then try to uninstall OpenJDK. That 
should do the trick. If you only have Oracle JDK installed, can you tell me the 
path to you `java` binary? It should be in 
`/usr/lib/jvm/jdk-7-oracle-armhf/jre/bin/`, but if it's somewhere else, we'll 
need to do something about that, thanks

Original comment by samuel.a...@gmail.com on 6 Feb 2014 at 1:06

GoogleCodeExporter commented 8 years ago
Hi, Samuel. Thanks for your advice. It solved my issue. Now I run in another 
problem:
g++ -I/usr/local/include/ -I/usr/lib/jvm/jdk-7-oracle-armhf/include 
-I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jnicvkernels.cpp 
-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mfpu=neon -ffast-math 
-Wl,-rpath,$ORIGIN/ -Wall -O3 -fPIC -shared -s -o 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvk
ernels.so -L/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ -lopencv_core
/usr/bin/ld: error: 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjnicvk
ernels.so uses VFP register arguments, /tmp/ccJzsIWo.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccJzsIWo.o
collect2: ld returned 1 exit status
I saw a solution on Stackoverflow 
http://stackoverflow.com/questions/9753749/arm-compilation-error-vpf-registered-
used-by-executable-not-object-file.
So my question is how do I add the compiler settings which are advised to solve 
this issue. Somewhere in the pom-File?
Thanks in advance

Original comment by mifun...@gmx.de on 7 Feb 2014 at 9:52

GoogleCodeExporter commented 8 years ago
Oh, it looks like unlike Android, most Linux distributions on ARM uses hardfp. 
I'll have to change that. Check these files here:
https://javacpp.googlecode.com/git/src/main/resources/com/googlecode/javacpp/pro
perties/
We can set these properties individually on the command line, or point the 
builder to another file entirely.

Original comment by samuel.a...@gmail.com on 9 Feb 2014 at 1:56

GoogleCodeExporter commented 8 years ago
Can you try the attached file with this command for me?
$ mvn clean package -Djavacpp.options="-propertyfile linux-arm.properties"
Thanks!

Original comment by samuel.a...@gmail.com on 10 Feb 2014 at 12:52

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the properties. I compiled javacpp with your properties and after 
that javacv
with mvn clean package -Djavacpp.options="-propertyfile 
../javacpp/src/main/resources/com/googlecode/javacpp/properties/linux-arm.proper
ties" -Dplatform.name=linux-arm

But the compilation fails with 
"/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniopencv_imgproc.
cpp: In function 'void 
Java_com_googlecode_javacv_cpp_opencv_1imgproc_adaptiveBilateralFilter(JNIEnv*, 
jclass, jobject, jobject, jobject, jdouble, jdouble, jobject, jint)':
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniopencv_imgproc.c
pp:8976:9: error: 'adaptiveBilateralFilter' is not a member of 'cv'" (full 
trace see below. Is it possible that something on the path is still missing? 
Thanks in advance
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JavaCV 0.7
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.3:clean (default-clean) @ javacv ---
[INFO] Deleting file set: /usr/opt/prj/javacv/target (included: [**], excluded: 
[])
[INFO]
[INFO] --- maven-dependency-plugin:2.3:properties (properties) @ javacv ---
[INFO]
[INFO] --- maven-dependency-plugin:2.3:copy-dependencies (copy-dependencies) @ 
javacv ---
[INFO] Copying javacpp-0.7.jar to /usr/opt/prj/javacv/target/javacpp.jar
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ javacv ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3:compile (default-compile) @ javacv ---
[INFO] Compiling 44 source files to /usr/opt/prj/javacv/target/classes
[INFO]
[INFO] --- exec-maven-plugin:1.2:exec (javacpp) @ javacv ---
....
g++ -I/usr/local/include/ -I/usr/lib/jvm/jdk-7-oracle-armhf/include 
-I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniopencv_imgproc.c
pp -Wl,-rpath,$ORIGIN/ -march=armv7-a -Wall -O3 -fPIC -shared -s -o 
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/linux-arm/libjniope
ncv_imgproc.so -L/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ -lopencv_imgproc 
-lopencv_core
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniopencv_imgproc.c
pp: In function 'void 
Java_com_googlecode_javacv_cpp_opencv_1imgproc_adaptiveBilateralFilter(JNIEnv*, 
jclass, jobject, jobject, jobject, jdouble, jdouble, jobject, jint)':
/usr/opt/prj/javacv/target/classes/com/googlecode/javacv/cpp/jniopencv_imgproc.c
pp:8976:9: error: 'adaptiveBilateralFilter' is not a member of 'cv'

Original comment by mifun...@gmx.de on 10 Feb 2014 at 9:22

GoogleCodeExporter commented 8 years ago
I had the same issue, using your separate properties file the build exists 
successfully

Original comment by rog...@in-ventid.nl on 10 Feb 2014 at 9:22

GoogleCodeExporter commented 8 years ago
Ok, the properties seems to be working, good. I've tried to make it a bit more 
general, so please try again with the attached one just to confirm, thanks.

As for the remaining compile error, you should try to upgrade to OpenCV 2.4.8.

Original comment by samuel.a...@gmail.com on 11 Feb 2014 at 1:16

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Samuel,

with your new settings and the switch to OpenCV 2.4.8 the compilation is 
successful. My VM cores when I first access OpenCV in Java but I think it's 
another issue because my build system isn't clean anymore. So I will build it 
on a clean system. If it still fails I'll come back to you :-). Neverthenless 
many thanks for your support.

Original comment by mifun...@gmx.de on 13 Feb 2014 at 9:22

GoogleCodeExporter commented 8 years ago
The fix has been included in the latest release of JavaCPP and JavaCV 0.8. This 
new version also comes with easier to use build scripts, so please take 
advantage of that to try out different sets of options to satisfy your needs.

A lot of other things have changed with this new version, so please make sure 
to read the news release here:
    http://bytedeco.org/release/2014/04/28/first-release.html

Incidentally, the project is now hosted on GitHub:
    https://github.com/bytedeco/javacv

Thanks for all your help on this issue! I am also looking for someone to 
provide builds for the "linux-arm" platform, so if you'd like to help out that 
way, please let me know, it would be very welcome.

Original comment by samuel.a...@gmail.com on 29 Apr 2014 at 1:19