Maven build for windows, linux and mac

845 views
Skip to first unread message

Stefan

unread,
Jun 14, 2015, 3:06:56 PM6/14/15
to jav...@googlegroups.com
Hey,
i am using maven to get the dependencies of JavaCv into my project. I could succesfully build a jar on windows, that runs on windows. When i try to execute the same jar on linux i get an "java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path". I thinks that's because i only included the windows-x86_64 version of the jars (these are the only ones i can see in eclipse under "Maven Dependencies"). In threads like this or this it looks like there are versions for linux and mac, but i can't get them through maven, for example with classifiers. How can i build my project, so it runs on windows, linux and mac?

Thanks, Stefan

Samuel Audet

unread,
Jun 14, 2015, 7:57:18 PM6/14/15
to javacv

Did you try to set the "platform.dependencies" system property to "true"?

Samuel

2015/06/15 4:06 "Stefan" <stefana...@gmail.com>:
Hey,
i am using maven to get the dependencies of JavaCv into my project. I could succesfully build a jar on windows, that runs on windows. When i try to execute the same jar on linux i get an "java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path". I thinks that's because i only included the windows-x86_64 version of the jars (these are the only ones i can see in eclipse under "Maven Dependencies"). In threads like this or this it looks like there are versions for linux and mac, but i can't get them through maven, for example with classifiers. How can i build my project, so it runs on windows, linux and mac?

Thanks, Stefan

--

---
You received this message because you are subscribed to the Google Groups "javacv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacv+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefan

unread,
Jun 14, 2015, 9:04:49 PM6/14/15
to jav...@googlegroups.com
i can't test this right now, but i think it should work now. The jars for all platforms are in my exported jar included, but it has 143mb now. Is there a way to just use certain parts of OpenCv/JavaCv and exclude others? Because i don't need any of the video processing or face detection or flandmark stuff, which are still exported and take up space.

Thanks, Stefan

Samuel Audet

unread,
Jun 15, 2015, 9:37:22 AM6/15/15
to jav...@googlegroups.com
On 06/15/2015 10:04 AM, Stefan wrote:
> i can't test this right now, but i think it should work now. The jars for
> all platforms are in my exported jar included, but it has 143mb now. Is
> there a way to just use certain parts of OpenCv/JavaCv and exclude others?
> Because i don't need any of the video processing or face detection
> or flandmark stuff, which are still exported and take up space.

Sure, it's possible trim out a lot of things with Maven: check the docs
about the pom.xml file. But if you start wanting to trim inside the
native libraries, you're going to need to rebuild those as well...

Samuel

Stefan

unread,
Jun 15, 2015, 11:27:37 AM6/15/15
to jav...@googlegroups.com
Sorry to bother you, but this is my first time using such a complex library, so i have no idea whats the structure behind it and how i could build it myself. It's also my first time using maven, so i already had a lot of problems to just set up and build my project.
I tried using maven shade plugin instead of maven assemly plugin to build my project, because you can set a flag minimizeJar, which should reduce the size of my final jar. After building, the size didn't change, instead i get an "Error loading class org/bytedeco/javacpp/Pointer." My imports look like this:
import static org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_imgproc.*;
import static org.bytedeco.javacpp.opencv_highgui.*;

import org.bytedeco.javacpp.opencv_core.CvRect;
import org.bytedeco.javacpp.opencv_core.IplImage;
import org.bytedeco.javacpp.indexer.UByteBufferIndexer;

So which jars or other files from JavaCv do i really need for my project to work and how could i exclude the ones i don't need?

Thanks for your great help,
Stefan

Stefan

unread,
Jun 16, 2015, 4:08:06 AM6/16/15
to jav...@googlegroups.com
And the problem runnign my project on linux isn't resolved. I exported my project on windows with the platform.dependencies flag, but it still doesn't work on linux. I then imported my maven project into eclipse on linux and tried to run it, but there i also get an "java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path". Maven downloaded the correct jars for linux, but somehow he can't find them. 
why does it work on windows but not on linux?

Thanks, Stefan

Samuel Audet

unread,
Jun 20, 2015, 3:48:35 AM6/20/15
to jav...@googlegroups.com
On 06/16/2015 12:27 AM, Stefan wrote:
> So which jars or other files from JavaCv do i really need for my project
> to work and how could i exclude the ones i don't need?

You could try to start by excluding dependencies you don't need with the
exclusions element of the dependency element, something like I did here
myself:
https://github.com/bytedeco/procamcalib/blob/master/pom.xml#L74

Samuel

Samuel Audet

unread,
Jun 20, 2015, 3:52:16 AM6/20/15
to jav...@googlegroups.com
On 06/16/2015 05:08 PM, Stefan wrote:
> And the problem runnign my project on linux isn't resolved. I exported
> my project on windows with the platform.dependencies flag, but it still
> doesn't work on linux. I then imported my maven project into eclipse on
> linux and tried to run it, but there i also get an
> "java.lang.UnsatisfiedLinkError: no jniopencv_core in
> java.library.path". Maven downloaded the correct jars for linux, but
> somehow he can't find them.
> why does it work on windows but not on linux?

I don't know, it works fine here. Could you try to run the Stitching
sample and let me know what happens? Thanks
https://github.com/bytedeco/javacpp-presets/tree/master/opencv

Samuel

Martin Deinhofer

unread,
Jun 22, 2015, 6:06:41 PM6/22/15
to jav...@googlegroups.com
Hi,


Am Montag, 15. Juni 2015 03:04:49 UTC+2 schrieb Stefan:
i can't test this right now, but i think it should work now. The jars for all platforms are in my exported jar included, but it has 143mb now. Is there a way to just use certain parts of OpenCv/JavaCv and exclude others? Because i don't need any of the video processing or face detection or flandmark stuff, which are still exported and take up space

Is it actually necessary to include also the 64bit binaries of e.g. opencv? I would say 32bit should run also on 64bit machines. So this way you could reduce the size significantly already. Another is to provide a javacv-specific jar for each platorm only containing the binaries for the respective platform.
Regards
Martin

Dan O'Keeffe

unread,
Jun 26, 2015, 7:00:41 PM6/26/15
to jav...@googlegroups.com
Hey,
For what it's worth, I had problems installing on linux because my GCC version was too old (Ubuntu 14.04). I followed the instructions here to add an external ppa in order to upgrade to a more recent version and that seemed to work. http://ubuntuforums.org/showthread.php?t=2262566

Dan
Reply all
Reply to author
Forward
0 new messages