Portability problem: How to compile for another computer without OpenCV?

749 views
Skip to first unread message

Gabriela Bosetti

unread,
Jul 30, 2012, 4:46:02 PM7/30/12
to jav...@googlegroups.com
Hi Samuel! Perhaps you remember me. I asked several questions relating to the same thing for over two months and I can not make this work ... Or maybe I fail to understand you well.
I follow your steps to compile and I could NEVER compile the way you indicate in http://code.google.com/p/javacv/wiki/HowToMakeAnApplet.

So, I downloaded
your applet on that page and examined it, and I can see that its structure is not like you mention in the instructions. For example, you say we have to
extract the 3 javacv JAR and the haarcascade to /aDirectory/ So, we should have this:

/aDirectory/javacpp
/aDirectory/com (Folder)
/aDirectory/javacv (Folder)
/aDirectory/lib (Folder)

Then, I understand you say we have to copy the .SO files to /aDirectory/com/googlecode/javacv/cpp/linux-x86_64     

There are the files I have copied there:

  • libopencv_calib3d.so.2.3.1
  • libopencv_contrib.so.2.3.1
  • libopencv_core.so.2.3.1
  • libopencv_features2d.so.2.3.1
  • libopencv_flann.so.2.3.1
  • libopencv_gpu.so.2.3.1
  • libopencv_highgui.so.2.3.1
  • libopencv_imgproc.so.2.3.1
  • libopencv_legacy.so.2.3.1
  • libopencv_ml.so.2.3.1
  • libopencv_objdetect.so.2.3.1
  • libopencv_video.so.2.3.1

BUT, when I look inside the JAR of your applet in http://code.google.com/p/javacv/wiki/HowToMakeAnApplet you only have ONE directory called /com/googlecode/ and inside it you have javacpp folder and javacv folder... There are a big difference! And maybe you forget to explain in instructions this.

Could you tell me step by step how to make an application that works on another computer without OpenCV, please? Even something as easy as loading an image, for example:

JFileChooser frmNavegador = new JFileChooser();
   
        frmNavegador.setDialogTitle("Seleccione una imágen");
        frmNavegador.setFileFilter(new FileNameExtensionFilter("JPG PNG", "jpg", "png"));
        frmNavegador.setCurrentDirectory(new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath().concat("/editorImagenes/Imagenes")));
   
        if (frmNavegador.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            IplImage iplUltima = opencv_highgui.cvLoadImage(frmNavegador.getSelectedFile().toString());
            ImageIcon iconImg = new ImageIcon(iplUltima.getBufferedImage());
            label.setIcon(iconImg);
        } else {
            System.out.println("Por favor, seleccione una imágen para comenzar.");
        }

Only the steps to compile and to make it work on another computer without OpenCV.

My problem is that my University professor has asked me to make a practical and chosen as a tool to JavaCV. I trusted that I would be able, and I have already done all the work done, but I can not make it run on my teacher's computer. Now all I have until 07 August to not fail ... And I'm going crazy. I have to know if you can explain to me because if you can not, I have to change the tool.


Thanks for your time,

Gabriela

Samuel Audet

unread,
Jul 31, 2012, 9:54:36 AM7/31/12
to jav...@googlegroups.com
On 2012-07-31 05:46, Gabriela Bosetti wrote:
> BUT, when I look inside the JAR of your applet in
> http://code.google.com/p/javacv/wiki/HowToMakeAnAppletyou only have ONE
> directory called /com/googlecode/ and inside it you have javacpp folder
> and javacv folder... There are a big difference! And maybe you forget to
> explain in instructions this.

When I type "unzip javacpp.jar" or "unzip javacv.jar" on my machine, I
get absolutely no top directory named either "javacpp" or "javacv".
There must be something funny with your version of unzip..

> Could you tell me step by step how to make an application that works on
> another computer without OpenCV, please? Even something as easy as
> loading an image, for example:

AFAIK, the instructions on that page work, what doesn't work for you?

> Only the steps to compile and to make it work on another computer
> without OpenCV.
>
> My problem is that my University professor has asked me to make a
> practical and chosen as a tool to JavaCV. I trusted that I would be
> able, and I have already done all the work done, but I can not make it
> run on my teacher's computer. Now all I have until 07 August to not fail
> ... And I'm going crazy. I have to know if you can explain to me because
> if you can not, I have to change the tool.

Well, let me know what doesn't work exactly, and we'll figure it out

Samuel

Gabriela Bosetti

unread,
Jul 31, 2012, 11:00:10 AM7/31/12
to jav...@googlegroups.com
Hi Samuel! Thanks for your time! Look, I did the next:

1) I extracted javacpp.jar javacv.jar and javacv-linux-x86_64.jar in a /Folder/. This brings me three folders called "/Folder/com", "/Folder/javacv" and "/Folder/javacpp".
2) I copied to the /Folder/ the file haarcascade_frontalface_alt.xml that I found in /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml
3) I copied all the OPENCV required library files (

     libopencv_calib3d.so.2.3.1 
     libopencv_contrib.so.2.3.1 
     libopencv_core.so.2.3.1 
     libopencv_features2d.so.2.3.1
     libopencv_flann.so.2.3.1 
     libopencv_gpu.so.2.3.1 
     libopencv_highgui.so.2.3.1 
     libopencv_imgproc.so.2.3.1
     libopencv_legacy.so.2.3.1 
     libopencv_ml.so.2.3.1 
     libopencv_objdetect.so.2.3.1
     libopencv_video.so.2.3.1)
     into the /Folder/com/googlecode/javacv/cpp/linux-x86_64
4) I have this tree files in /Folder/: FaceApplet.html FaceApplet.java and FaceApplet.jnlp. These tree are what you provide in Samples Folders. But when I do
cd /home/gaby/workspace/javacv-bin/Folder/
javac FaceApplet.java


It throws 25 errors like the next:
FaceApplet.java:9: package com.googlecode.javacpp does not exist
import com.googlecode.javacpp.Loader;

So I do: javac -cp "$CLASSPATH:.:/home/gaby/workspace/javacv-bin/Folder/ " FaceApplet.java
but the errors still appears.

In another post you said that is because I am not including in the classpath the three folders,
but I tried to include them in every way and the error is always the same:
"FaceApplet.java: 9: package does com.googlecode.javacpp not exist. "

Then, I browse to /Folder/com/googlecode/ and there is no JavaCPP folder! javacpp folder is in /Folder/.
And if I copy the /jacacpp/ folder into /Folder/com/gooclegode/ the error is the same!


Message has been deleted

Gabriela Bosetti

unread,
Jul 31, 2012, 11:34:07 AM7/31/12
to jav...@googlegroups.com
Other ways to compile I tried and that throws the same error:

    • javac -cp "$CLASSPATH:.:/home/gaby/workspace/javacv-bin/Folder/ " FaceApplet.java
    • javac -classpath .;/home/gaby/workspace/javacv-bin/Folder FaceApplet.java
    • cd ../Folder/     
      javac -classpath . FaceApplet.java 
    • cd ../Folder/     
      javac -sourcepath . -classpath . FaceApplet.java
    • javac -sourcepath .;/home/gaby/workspace/javacv-bin/Folder -classpath .;/home/gaby/workspace/javacv-bin/Folder  FaceApplet.java -d classes

    So, how do you compile for my files? I remind my files:

    /Folder/

    • /Folder/
      • FaceApplet.html
      • FaceApplet.java
      • FaceApplet.jnlp
      • haarcascade_frontalface_alt.xml
      • javacpp
      • javacv
      • com
        • googlecode/javacv/cpp/linux-x86_64 
          • libopencv_calib3d.so.2.3.1
          • libopencv_contrib.so.2.3.1
          • libopencv_core.so.2.3.1
          • libopencv_features2d.so.2.3.1
          • libopencv_flann.so.2.3.1
          • libopencv_gpu.so.2.3.1
          • libopencv_highgui.so.2.3.1
          • libopencv_imgproc.so.2.3.1
          • libopencv_legacy.so.2.3.1
          • libopencv_ml.so.2.3.1
          • libopencv_objdetect.so.2.3.1
          • libopencv_video.so.2.3.1

    El martes, 31 de julio de 2012 10:54:36 UTC-3, Samuel Audet escribió:

    Samuel Audet

    unread,
    Aug 1, 2012, 9:45:31 AM8/1/12
    to jav...@googlegroups.com
    On 2012-08-01 00:00, Gabriela Bosetti wrote:
    > Hi Samuel! Thanks for your time! Look, I did the next:
    >
    > 1) I extracted javacpp.jar javacv.jar and javacv-linux-x86_64.jar in a
    > /Folder/. This brings me three folders called "/Folder/com",
    > "/Folder/javacv" and "/Folder/javacpp".

    Well don't do that. Put everything in /Folder/

    > In another post you said that is because I am not including in the classpath the three folders,
    > but I tried to include them in every way and the error is always the same:
    > "FaceApplet.java: 9: package does com.googlecode.javacpp not exist."
    >
    > Then, I browse to /Folder/com/googlecode/ and there is no JavaCPP folder! javacpp folder is in /Folder/.
    > And if I copy the /jacacpp/ folder into /Folder/com/gooclegode/ the error is the same!

    Just do it the same way that they are found in FaceApplet.jar. Copy the
    files one by one in the right directory if you have to, or get a better
    unzip program

    Gabriela Bosetti

    unread,
    Aug 2, 2012, 1:31:19 AM8/2/12
    to jav...@googlegroups.com
    THANKS SAMUEL!! You are right, the problem was my unzipper. Now I can compile BUT there are a problem when I try to run the applet, it throws:
    com.googlecode.javacv.FrameGrabber$Exception: cvCreateCameraCapture() Error: Could not create... (here finishes the applet and I can't see more)

    And it's strange because your applet works when entering to http://code.google.com/p/javacv/wiki/HowToMakeAnApplet.
    But
    what I compile doesnt work!
    Any idea why?

    Thanks for your time!!!!!

    Samuel Audet

    unread,
    Aug 2, 2012, 8:09:30 AM8/2/12
    to jav...@googlegroups.com
    On 2012-08-02 14:31, Gabriela Bosetti wrote:
    > THANKS SAMUEL!! You are right, the problem was my unzipper. Now I can
    > compile BUT there are a problem when I try to run the applet, it throws:

    Great, now that I think about it, "jar" is a fine unzipper, so I've
    updated the instructions to show users how to use jar to unzip that
    properly.

    > com.googlecode.javacv.FrameGrabber$Exception: cvCreateCameraCapture()
    > Error: Could not create... (here finishes the applet and I can't see more)
    >
    > And it'sstrange because your applet works when entering to
    > http://code.google.com/p/javacv/wiki/HowToMakeAnApplet.
    > But what I compile doesnt work!
    > Any idea why?

    You're probably missing some of the required DLLs as explained in the
    instructions. And check inside FaceApplet.java to see what modules are
    imported

    Samuel

    Gabriela Bosetti

    unread,
    Aug 2, 2012, 3:03:59 PM8/2/12
    to jav...@googlegroups.com
    Solved! You are right! Now I can compile and run my applet... BUT (I have always a BUT lol hehe) when I try to run in another computer without OpenCV it doesnt work --> Applet not initialized.

    I thought that I had done something wrong again, but then I entered from that computer to your page and your applet not initialized neither.

    I have installed the icedtea, so it should work...

    Samuel Audet

    unread,
    Aug 3, 2012, 10:51:19 AM8/3/12
    to jav...@googlegroups.com
    On 2012-08-03 04:03, Gabriela Bosetti wrote:
    > Solved! You are right! Now I can compile and run my applet... BUT (I
    > have always a BUT lol hehe) when I try to run in another computer
    > without OpenCV it doesnt work --> Applet not initialized.
    >
    > I thought that I had done something wrong again, but then I entered from
    > that computer to your page and your applet not initializedneither.
    >
    > I have installed the icedtea, so it should work...

    Looks like they don't have an implementation compatible Java SE 6, you
    need to install that...

    Samuel

    Gabriela Bosetti

    unread,
    Aug 7, 2012, 7:13:31 PM8/7/12
    to jav...@googlegroups.com
    sorry to say that without OpenCV installed your applet doesn't run. Try to run the applet without opencv. This is the error:

    UnsatisfiedLinkError /tmp/javacpp189287310927/libjniopencv_highgui.so: libopencv_highgui.so.2.4: cannot open shared object file: No such file or directory.

    Java Plug-in 10.0.0.06
    Using JRE version 1.7.0_05-b06 Java HotSpot(TM) 64-Bit Server VM
    User home directory = /home/gaby
    ----------------------------------------------------
    c:   clear console window
    f:   finalize objects on finalization queue
    g:   garbage collect
    h:   display this help message
    l:   dump classloader list
    m:   print memory usage
    o:   trigger logging
    q:   hide console
    r:   reload policy configuration
    s:   dump system and deployment properties
    t:   dump thread list
    v:   dump thread stack
    x:   clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------
    plugin2manager.parentwindowDispose
    attributes length: 2
    attributes length: 2
    attributes length: 1
    attributes length: 1
    plugin2manager.parentwindowDispose
    CacheEntry[http://wiki.javacv.googlecode.com/git/FaceApplet.jar]: updateAvailable=false,lastModified=Thu Jan 01 00:00:00 GMT 1970,length=-1

    Gabriela Bosetti

    unread,
    Aug 7, 2012, 7:14:09 PM8/7/12
    to jav...@googlegroups.com
    When I say your applet I mean this --> http://code.google.com/p/javacv/wiki/HowToMakeAnApplet

    Gabriela Bosetti

    unread,
    Aug 7, 2012, 7:17:08 PM8/7/12
    to jav...@googlegroups.com
    And Java works fine. I tryed with icedtea from openJDK and with the plugin from Oracle Java.

    Gabriela Bosetti

    unread,
    Aug 7, 2012, 8:12:32 PM8/7/12
    to jav...@googlegroups.com
    I'm under Linux 64. Under Windows your applet runs. The problem is under any Linux.

    Samuel Audet

    unread,
    Aug 7, 2012, 9:14:08 PM8/7/12
    to jav...@googlegroups.com
    Works fine here, without OpenCV installed, 64-bit Linux. Please let me know if you figure out why it doesn't work on your machine, thanks


    On 08/08/2012 09:12 AM, Gabriela Bosetti wrote:

    Gabriela Bosetti

    unread,
    Aug 8, 2012, 9:38:04 PM8/8/12
    to jav...@googlegroups.com
    Samuel: I ask you help, please. JavaCV really does not work without OpenCV installed. I just reformatted my computer, I installed only Ubuntu 64, OpenJDK6 and IcedTea6 and your applet does not work. Applets generally work, but when running a line with JavaCV not work.

    I followed your instructions step by step and nothing works. Really, I just convince myself that does not work because I tried OracleJava and OpenJDK on a formatted system and doesnt work. There is always error.




    Gabriela Bosetti

    unread,
    Aug 8, 2012, 9:39:21 PM8/8/12
    to jav...@googlegroups.com
    The error seems to be that libraries are not copied to the temporary folder "/ tmp/javacpp6211371031945".





    El martes, 7 de agosto de 2012 22:14:08 UTC-3, Samuel Audet escribió:

    Gabriela Bosetti

    unread,
    Aug 8, 2012, 9:40:09 PM8/8/12
    to jav...@googlegroups.com
    Exception in thread "AWT-EventQueue-1" java.lang.UnsatisfiedLinkError: /tmp/javacpp6561976091760/libjniopencv_core.so: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)

    Gabriela Bosetti

    unread,
    Aug 8, 2012, 9:41:07 PM8/8/12
    to jav...@googlegroups.com
    And Java is already running, I know because this page works: http://www.java.com/en/download/testjava.jsp

    Samuel Audet

    unread,
    Aug 8, 2012, 9:42:26 PM8/8/12
    to jav...@googlegroups.com
    On 08/09/2012 10:39 AM, Gabriela Bosetti wrote:
    > The error seems to be that libraries are not copied to the temporary
    > folder "/ tmp/javacpp6211371031945".

    How do you know that?

    Gabriela Bosetti

    unread,
    Aug 8, 2012, 11:22:34 PM8/8/12
    to jav...@googlegroups.com
    the applet was not working as compiled manually (it is compilled without errors, but when I run nothing happends), so I imported the code to netbeans and put a breakpoint on the first line of "javacv". When I run the first line an error is throwed that says:

    Exception in thread "AWT-EventQueue-1" java.lang.
    UnsatisfiedLinkError: /tmp/javacpp6561976091760/libjniopencv_core.so: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)

    So, I open /tmp/javacpp6561976091760/ and there is nothing!

    Samuel Audet

    unread,
    Aug 9, 2012, 1:01:12 AM8/9/12
    to jav...@googlegroups.com
    Can you try again with the original file without manually compiling
    anything?

    Gabriela Bosetti

    unread,
    Aug 9, 2012, 1:41:02 AM8/9/12
    to jav...@googlegroups.com
    Yes, but it's displaying a gray screen. It says "starting applet", then appears your signature popup, I accept it, and then "stop: applet not initialized".
    So, in my nOtebook, without opencv, your applet doesnt work.
    But in my nEtbook, where I have OpenCV installed, it works!
    What I can do??

    Gabriela Bosetti

    unread,
    Aug 9, 2012, 1:44:50 AM8/9/12
    to jav...@googlegroups.com
    iT IS SO SO SO extrange, because I have installed exactly the same OS (Ubuntu 64) and exactly the same rograms, exactly the same openJDK and icedTea... The only difference is that one have opencv and the other not.

    Samuel Audet

    unread,
    Aug 9, 2012, 1:49:04 AM8/9/12
    to jav...@googlegroups.com
    On 08/09/2012 02:41 PM, Gabriela Bosetti wrote:
    > Yes, but it's displaying a gray screen. It says "starting applet", then
    > appearsyour signaturepopup, I accept it, and then "stop: applet not
    > initialized".
    > So, in my nOtebook, without opencv, your applet doesnt work.
    > But in my nEtbook, where I have OpenCV installed, it works!
    > What I can do??

    Then debug it and let me know if you figure out what the problem is,
    thank you

    Gabriela Bosetti

    unread,
    Aug 10, 2012, 2:31:10 AM8/10/12
    to jav...@googlegroups.com
    I really don't know what happends on Ubuntu. Still doesnt work, but i migrated to Windows and I did it!!!
    Thanks so much Samuel!!!!
    Here my instructions on spanish (maybe it can help someone):
    http://devel-open.blogspot.com.ar/2012/08/como-crear-un-applet-con-javacv-windows.html

    When I finish my work, I will share my code with you, maybe can be useful as another example in PURE java.
    THANKSSSS!!!

    Gabriela Bosetti

    unread,
    Aug 12, 2012, 8:43:57 PM8/12/12
    to jav...@googlegroups.com
    I think I know what is the problem! I think the problem in Ubuntu is something related with dependencies between opencv libs and tbb. I try to see your applet only with Java and it doesnt work, it throws an error saying highgui cant be loaded, but then I installed OpenCV, and it works. Then I deleted all the files on /usr/local/lib/libopencv* and your applet still work, so then I deleted the folder /usr/include/tbb and it doesnt work again.

    MAybe we need to include something from tbb jo the cpp.jar?

    Gabriela Bosetti

    unread,
    Aug 12, 2012, 9:36:34 PM8/12/12
    to jav...@googlegroups.com
    What are your cmake params to make OpenCV? The mine is: cmake -D WITH_QT=OFF -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON ..

    Jose Gómez

    unread,
    Feb 8, 2013, 5:31:26 AM2/8/13
    to jav...@googlegroups.com
    Hi Gabriela,
     
    I was trying some things related to my other thread (https://groups.google.com/forum/#!topic/javacv/VI1ikAnXaXA), and after some tries, the application is working fine in a Ubuntu 64 pc with OpenCV installed. But when I try to run it in a separate machine (Ubuntu 32 with OpenCV not installed), I get the UnsatisfiedLinkError that you mention, even if I have included the native libraries.
     
    What I haven't tried yet in this PC without OpenCV is the sample applet. I will try it later, and see if it works.
     
    Were you able to get to make it work in a Linux PC without OpenCV installed?
     
     
    Regards,
     
    Jose Gómez.

    Gabriela Bosetti

    unread,
    Feb 8, 2013, 8:10:43 AM2/8/13
    to jav...@googlegroups.com
    Hi José! No, I coudn't do that... :-(
    It only works on Windows, and I can't say anything about Mac because I don have one.
    If you can, please tell us how.

    Here I have my results (spanish posts):
    http://devel-open.blogspot.com.ar/search/label/javacv

    Regards,
    Gaby


    --
     
    ---
    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/groups/opt_out.
     
     

    Jose Gómez

    unread,
    Feb 8, 2013, 8:13:17 PM2/8/13
    to jav...@googlegroups.com
    For the time being, I have checked a few things:
    • HowToMakeAnApplet also doesn't work in this Ubuntu x32 machine without OpenCV libs installed.
    • The .so libraries included in FaceApplet.jar do not have missing dependencies, apart from the opencv files that are not included in the jar, and the libtiff library, which is also not installed in my system, so it is not required.
    • There is no reference whatsoever to libtbb, neither in the Linux libraries, nor in the JNI interfaces. So, TBB is not being used in the binaries currently included in HowToMakeAnApplet, and therefore, the lack of it should not have any impact.

    Regards,

    Jose Gómez.

    Samuel Audet

    unread,
    Feb 9, 2013, 3:57:56 AM2/9/13
    to jav...@googlegroups.com
    On 02/09/2013 10:13 AM, Jose Gómez wrote:
    For the time being, I have checked a few things:
    • HowToMakeAnApplet also doesn't work in this Ubuntu x32 machine without OpenCV libs installed.
    • The .so libraries included in FaceApplet.jar do not have missing dependencies, apart from the opencv files that are not included in the jar, and the libtiff library, which is also not installed in my system, so it is not required.
    • There is no reference whatsoever to libtbb, neither in the Linux libraries, nor in the JNI interfaces. So, TBB is not being used in the binaries currently included in HowToMakeAnApplet, and therefore, the lack of it should not have any impact.

    In the case of Linux, to get maximum portability, we need to build the libraries with the oldest version of Linux, GCC and glibc that gets our stuff compiled. It may be possible that the version of Ubuntu you are using is older than the version of Linux (Fedora 14) that I used to compile that demo applet... Is it?

    And what do you mean by the "opencv files that are not included in the jar"? I compiled  the libs with dependencies on libtiff, etc, but if it's something that is causing trouble, then that's another thing to check off the list in CMake when building libraries for Linux.

    Samuel

    Jose Gómez

    unread,
    Feb 9, 2013, 8:03:06 AM2/9/13
    to jav...@googlegroups.com
    This computer uses Ubuntu 12.10 32bits, so its libraries should be reasonably recent. The lack of libtiff is not a problem in my own pc, so it should also not be a problem in this other pc.

    The 4 native OpenCV files included in the linux-x86 folder of FaceApplet.jar are:
    • libopencv_core.so.2.4
    • libopencv_highgui.so.2.4
    • libopencv_imgproc.so.2.4
    • libopencv_objdetect.so.2.4
    But these 4 libraries doesn't have any dependencies with the remaining OpenCV libs. With those "opencv files that are not included in the jar" I mean the remaining openvc files:
    • libopencv_calib3d.so.2.4
    • libopencv_contrib.so.2.4
    • libopencv_features2d.so.2.4
    • libopencv_flann.so.2.4
    • libopencv_gpu.so.2.4
    • libopencv_legacy.so.2.4
    • libopencv_ml.so.2.4
    • libopencv_nonfree.so.2.4
    • libopencv_photo.so.2.4
    • libopencv_stitching.so.2.4
    • libopencv_ts.so.2.4
    • libopencv_video.so.2.4
    • libopencv_videostab.so.2.4
    These are not being included in FaceApplet.jar. They are probably not required anyway, or at least the 4 files included do not depend on them.


    --

    Jose Gómez

    unread,
    Feb 9, 2013, 8:18:40 AM2/9/13
    to jav...@googlegroups.com
    Furthermore, this is the error I get using my own jnlp with the native libs from FaceApplet included:

    net.sourceforge.jnlp.
    LaunchException: Fatal: Launch Error: Could not launch JNLP file.
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:600)
        at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:889)
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:594)
        ... 1 more
    Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp4583043678568/libjniopencv_highgui.so: libopencv_highgui.so.2.4: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1646)
        at java.lang.Runtime.load0(Runtime.java:787)
        at java.lang.System.load(System.java:1022)
        at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:422)
        at com.googlecode.javacpp.Loader.load(Loader.java:372)
        at com.googlecode.javacpp.Loader.load(Loader.java:319)
        at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
        at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174)
        at org.dreamcoder.opencv.javacv.javacvtestjnlp.FaceDetection.main(FaceDetection.java:74)
        ... 6 more

    If at that time I check the /tmp/javacpp4583043678568/ folder, it contains just the files:
    • libjniopencv_core.so
    • libopencv_core.so.2.4
    • libjniopencv_imgproc.so
    • libopencv_imgproc.so.2.4
    But no sign of the remaining files, and especifically, not libjniopencv_highgui.so and libopencv_highgui.so.2.4, which appear in the error.

    Maybe they are being copied to the tmp folder in a reverse order? Is that why libjniopencv_highgui.so can't be copied, as libopencv_highgui.so.2.4 is not in the folder yet?


    Regards,

    Jose.

    Samuel Audet

    unread,
    Feb 10, 2013, 7:21:45 AM2/10/13
    to jav...@googlegroups.com
    On 02/09/2013 10:03 PM, Jose G�mez wrote:
    > This computer uses Ubuntu 12.10 32bits, so its libraries should be
    > reasonably recent. The lack of libtiff is not a problem in my own pc, so
    > it should also not be a problem in this other pc.

    Well, maybe you're missing some other libraries like libjasper? Check
    the error message anyway, it should tell you what it's looking for.

    > If at that time I check the /tmp/javacpp4583043678568/ folder, it contains just the files:
    >
    > libjniopencv_core.so
    > libopencv_core.so.2.4
    > libjniopencv_imgproc.so
    > libopencv_imgproc.so.2.4
    >
    > But no sign of the remaining files, and especifically, not libjniopencv_highgui.so and libopencv_highgui.so.2.4, which appear in the error.
    >
    > Maybe they are being copied to the tmp folder in a reverse order? Is that why libjniopencv_highgui.so can't be copied, as libopencv_highgui.so.2.4 is not in the folder yet?

    Maybe they've been deleted already, that's why they might not be there.
    To make sure that it does actually get extracted, we'd have to put a
    breakpoint here:
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:422)

    I'm pretty sure it gets extracted though. The error message doesn't look
    like the right one for some reason, so make sure you have all the
    dependencies listed by `ldd` installed on your machine.

    Samuel

    Gabriela Bosetti

    unread,
    Feb 10, 2013, 12:47:58 PM2/10/13
    to jav...@googlegroups.com
    I believe that there is nothing we can do, José. JavaCV not designed for Ubuntu. I tried everything and I could never run HowToMakeAnApplet not even the example that should work online.



    On 10 February 2013 09:21, Samuel Audet <samuel...@gmail.com> wrote:


    Samuel

    --

    --- 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+unsubscribe@googlegroups.com.

    Jose Gómez

    unread,
    Feb 10, 2013, 2:54:11 PM2/10/13
    to jav...@googlegroups.com
    Hi,

    libjasper is installed in both machines, and the only libraries that are missing are libjpeg and libtiff in my machine, and just libtiff in the x86 machine. All the remaining dependencies are found by ldd.

    I have just realized that, in my own machine, depending on the libopencv_* libraries used, not all may be copied to the /tmp/javacpp folder. However, as I have OpenCV installed, the JNI interface still finds the native library. However, when JavaCPP copies the library, it correctly uses as a source the one in the jar (not the one installed in the system).

    So, what could be the reason why JavaCPP is sometimes not copying a library to the /tmp/javacppxxx folder?

    I have also realized that this exact problem also exists with the sample FaceApplet. When I run it, if at that time I check the tmp folder, I see that the library libopencv_highgui.so.2.4 has not been copied:

    adler@adlerG1:/tmp/javacpp44716600480401$ ls -l
    total 6048
    -rw-rw-r-- 1 adler adler  213544 Feb 10 19:49 libjnidc1394.so
    -rw-rw-r-- 1 adler adler  653960 Feb 10 19:49 libjniopencv_core.so
    -rw-rw-r-- 1 adler adler   66120 Feb 10 19:49 libjniopencv_highgui.so
    -rw-rw-r-- 1 adler adler  258496 Feb 10 19:49 libjniopencv_imgproc.so
    -rw-rw-r-- 1 adler adler  266920 Feb 10 19:49 libjniopencv_objdetect.so
    -rw-rw-r-- 1 adler adler 2264048 Feb 10 19:49 libopencv_core.so.2.4
    -rw-rw-r-- 1 adler adler 1904712 Feb 10 19:49 libopencv_imgproc.so.2.4
    -rw-rw-r-- 1 adler adler  542288 Feb 10 19:49 libopencv_objdetect.so.2.4

    So, it looks like a bug in JavaCPP, or any kind of strange behaviour depending on the libraries used.

    On the other hand, I have also tried using the "nativelibs" tag in JNLP, leaving the native libraries on the root of the jar, with no success (so far). I guess JavaCPP is not using at all the standard method provided by JNLP.


    Regards,

    Jose Gómez.
    To unsubscribe from this group and stop receiving emails from it, send an email to javacv+un...@googlegroups.com.

    Samuel Audet

    unread,
    Feb 10, 2013, 9:04:59 PM2/10/13
    to jav...@googlegroups.com
    Grabiel,

    JavaCV should be easier to rebuild than the last time you tried. So, if
    you can build OpenCV with CMake, JavaCPP and JavaCV should build with a
    simple `mvn clean install` command...

    Samuel

    On 02/11/2013 02:47 AM, Gabriela Bosetti wrote:
    > I believe that there is nothing we can do, Jos�. JavaCV not designed for

    Samuel Audet

    unread,
    Feb 10, 2013, 9:33:03 PM2/10/13
    to jav...@googlegroups.com
    Hello,

    On 02/11/2013 04:54 AM, Jose G�mez wrote:
    > I have just realized that, in my own machine, depending on the
    > libopencv_* libraries used, not all may be copied to the /tmp/javacpp
    > folder. However, as I have OpenCV installed, the JNI interface still
    > finds the native library. However, when JavaCPP copies the library, it
    > correctly uses as a source the one in the jar (not the one installed in
    > the system).

    If it gets copies, Linux does the loading. This isn't JavaCPP doing the
    loading at that point.

    > So, what could be the reason why JavaCPP is sometimes not copying a
    > library to the /tmp/javacppxxx folder?
    >
    > I have also realized that this exact problem also exists with the sample
    > FaceApplet. When I run it, if at that time I check the tmp folder, I see
    > that the library libopencv_highgui.so.2.4 has not been copied:
    >
    > adler@adlerG1:/tmp/javacpp44716600480401$ ls -l
    > total 6048
    > -rw-rw-r-- 1 adler adler 213544 Feb 10 19:49 libjnidc1394.so
    > -rw-rw-r-- 1 adler adler 653960 Feb 10 19:49 libjniopencv_core.so
    > -rw-rw-r-- 1 adler adler 66120 Feb 10 19:49 libjniopencv_highgui.so
    > -rw-rw-r-- 1 adler adler 258496 Feb 10 19:49 libjniopencv_imgproc.so
    > -rw-rw-r-- 1 adler adler 266920 Feb 10 19:49 libjniopencv_objdetect.so
    > -rw-rw-r-- 1 adler adler 2264048 Feb 10 19:49 libopencv_core.so.2.4
    > -rw-rw-r-- 1 adler adler 1904712 Feb 10 19:49 libopencv_imgproc.so.2.4
    > -rw-rw-r-- 1 adler adler 542288 Feb 10 19:49 libopencv_objdetect.so.2.4
    >
    >
    > So, it looks like a bug in JavaCPP, or any kind of strange behaviour
    > depending on the libraries used.

    There might be a bug, but it doesn't happen here:
    -rw-rw-r--. 1 saudet saudet 213544 Feb 11 11:27 libjnidc1394.so
    -rw-rw-r--. 1 saudet saudet 116072 Feb 11 11:27 libjnifreenect.so
    -rw-rw-r--. 1 saudet saudet 653960 Feb 11 11:27 libjniopencv_core.so
    -rw-rw-r--. 1 saudet saudet 66120 Feb 11 11:27 libjniopencv_highgui.so
    -rw-rw-r--. 1 saudet saudet 258496 Feb 11 11:27 libjniopencv_imgproc.so
    -rw-rw-r--. 1 saudet saudet 266920 Feb 11 11:27 libjniopencv_objdetect.so
    -rw-rw-r--. 1 saudet saudet 2264048 Feb 11 11:27 libopencv_core.so.2.4
    -rw-rw-r--. 1 saudet saudet 235560 Feb 11 11:27 libopencv_highgui.so.2.4
    -rw-rw-r--. 1 saudet saudet 1904712 Feb 11 11:27 libopencv_imgproc.so.2.4
    -rw-rw-r--. 1 saudet saudet 542288 Feb 11 11:27 libopencv_objdetect.so.2.4


    > On the other hand, I have also tried using the "nativelibs" tag in JNLP,
    > leaving the native libraries on the root of the jar, with no success (so
    > far). I guess JavaCPP is not using at all the standard method provided
    > by JNLP.

    No, it doesn't use any of that because it doesn't work without Web
    Start. I think the way I'm doing it in JavaCPP works better in any case.
    IMO, the JDK should adopt that method :)

    Samuel

    Jose Gómez

    unread,
    Feb 10, 2013, 9:59:51 PM2/10/13
    to jav...@googlegroups.com
    The copy of files or not seems to depend on the libraries being copied, or maybe of what is existing in the system... I have no clue from where to start investigating. If the files are in the jar, it is very strange for it to decide to download some of them them or not.

    I have had a look to the Loader class, but I am not familiar with it, and there are no comments at all, so it is hard for me to figure out what is the class doing and how, and therefore, debug it. I think I'll just embed all the JavaCV sources in my project, and start putting breakpoints in the Loader class...



    On Monday, February 11, 2013 2:33:03 AM UTC, Samuel Audet wrote:
    Hello,

    Samuel Audet

    unread,
    Feb 10, 2013, 10:44:56 PM2/10/13
    to jav...@googlegroups.com
    On 02/11/2013 11:59 AM, Jose G�mez wrote:
    > The copy of files or not seems to depend on the libraries being copied,
    > or maybe of what is existing in the system... I have no clue from where
    > to start investigating. If the files are in the jar, it is very strange
    > for it to decide to download some of them them or not.
    >
    > I have had a look to the Loader class, but I am not familiar with it,
    > and there are no comments at all, so it is hard for me to figure out
    > what is the class doing and how, and therefore, debug it. I think I'll
    > just embed all the JavaCV sources in my project, and start putting
    > breakpoints in the Loader class...

    I think the code is pretty easy to follow.. I tend to use long names for
    identifiers and actually try to make them mean something, but yeah it
    could use some more Javadoc-style documentation for methods... It was
    mostly an experiment to attract some attention to the idea, but I guess
    people have mostly given up on that and summarily ignore anything
    related to this kind of tool.

    Anyhow, I've made a couple of changes since, so make sure to get the
    latest source from the repo, but the place where files get extracted is
    in Loader.extractResource(), and the only place where is gets called by
    load() is here:
    http://code.google.com/p/javacpp/source/browse/src/main/java/com/googlecode/javacpp/Loader.java#430
    which gets executed for all "link" and "preload" libraries in this loop:
    http://code.google.com/p/javacpp/source/browse/src/main/java/com/googlecode/javacpp/Loader.java#379

    So, for whatever reason, it seems it's not getting there for these files
    on your machine... If you figure out why, please let me know!

    Let's see, looking at that code, it looks like when an
    UnsatisfiedLinkError gets thrown, it silently ignores it and the file
    gets deleted! Whoops, I guess I should figure out a way to not do
    that... Anyway, this means that the files get deleted because Linux
    can't find the dependent libraries as I suspected.

    Samuel

    Samuel Audet

    unread,
    Feb 11, 2013, 2:46:32 AM2/11/13
    to jav...@googlegroups.com
    On 02/11/2013 12:44 PM, Samuel Audet wrote:
    > Let's see, looking at that code, it looks like when an
    > UnsatisfiedLinkError gets thrown, it silently ignores it and the file
    > gets deleted! Whoops, I guess I should figure out a way to not do
    > that... Anyway, this means that the files get deleted because Linux
    > can't find the dependent libraries as I suspected.

    Ok, I fixed that. We should get better error messages with this update:
    http://code.google.com/p/javacpp/source/detail?r=d5d47a5d7b3d8488ca7d98e92c5e65334ec43208

    Samuel

    Jose Gómez

    unread,
    Feb 11, 2013, 7:00:33 PM2/11/13
    to jav...@googlegroups.com
    Using the latest JavaCPP version, I have got a more detailed exception:

    net.sourceforge.jnlp.LaunchException: Fatal: Launch Error: Could not launch JNLP file. 
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:600)
        at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:889)
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:594)
        ... 1 more
    Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp37002913502004/libjniopencv_highgui.so: libtiff.so.3: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1646)
        at java.lang.Runtime.load0(Runtime.java:787)
        at java.lang.System.load(System.java:1022)
        at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:465)
        at com.googlecode.javacpp.Loader.load(Loader.java:399)
        at com.googlecode.javacpp.Loader.load(Loader.java:347)
        at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
        at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174)
        at org.dreamcoder.opencv.javacv.javacvtestjnlp.FaceDetection.main(FaceDetection.java:75)
        ... 6 more
    Caused by: java.lang.UnsatisfiedLinkError: /tmp/javacpp37002913502004/libopencv_highgui.so.2.4: libtiff.so.3: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1646)
        at java.lang.Runtime.load0(Runtime.java:787)
        at java.lang.System.load(System.java:1022)
        at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:465)
        at com.googlecode.javacpp.Loader.load(Loader.java:389)
        ... 10 more

    So, libopencv_highgui.so.2.4 could not load because libtiff.so.3 was not installed in the system. Both libtiff.so.4 and libtiff.so.5 were installed, but not libtiff.so.3. So, creating a link from .4 to .3, the application runs! :)

    You were right, it was a dependency issue. It didn't show in my system, because even if libtiff.so.3 is not installed here either, the version that I am using for x86_64 points to libtiff.so.5. And that was the same reason why FaceApplet did not work either. With the link created, FaceApplet also works.

    I can't request the users of my application to check dependencies of the libraries contained in the jars, and create symbolic links.

    So, the proper solution should be: recompile OpenCV with minimum options, and pray. I don't think we can integrate apt-get in JavaCPP... Or can we?

    Or could we have JavaCPP keep searching other libtiff.so.*, just in case? Would that be a reasonable solution, or would it be too risky? In the end, even the solution of recompiling will eventually be a problem, as eventually the libraries referenced will become old and cease to be installed by default, or even available in the repositories.

    What is clear is that this is a real possibility, so we need to give a user-friendly solution (automatic or not), or error message that will help the user fix the issue.


    Regards,

    Jose Gómez.

    Samuel Audet

    unread,
    Feb 12, 2013, 8:09:32 AM2/12/13
    to jav...@googlegroups.com
    On 02/12/2013 09:00 AM, Jose G�mez wrote:
    > I can't request the users of my application to check dependencies of the
    > libraries contained in the jars, and create symbolic links.
    >
    > So, the proper solution should be: recompile OpenCV with minimum

    Yes, and on the oldest version of Linux possible, or we end up depending
    on new versions of glibc.

    > options, and pray. I don't think we can integrate apt-get in JavaCPP...
    > Or can we?

    Well, the apt-get won't work on half the Linux distro out there anyway

    > Or could we have JavaCPP keep searching other libtiff.so.*, just in
    > case? Would that be a reasonable solution, or would it be too risky? In

    It's not usually a good idea to try to use a library whose version
    number indicates that the ABI is incompatible, no.

    > the end, even the solution of recompiling will eventually be a problem,
    > as eventually the libraries referenced will become old and cease to be
    > installed by default, or even available in the repositories.

    glibc, libstdc++, zlib and a couple of others try to maintain backward
    compatibility, so as long as it doesn't depend on other libraries than
    that, it should work..

    > What is clear is that this is a real possibility, so we need to give a
    > user-friendly solution (automatic or not), or error message that will
    > help the user fix the issue.

    There's never a clear answer about what works and what doesn't. We just
    have to try it out :)

    Samuel

    Jose Gómez

    unread,
    Feb 12, 2013, 3:29:15 PM2/12/13
    to jav...@googlegroups.com
    I know it is not right, but creating a link from the name of an older version of the library to the new one quite often works, as it does in this case.

    Anyway, we need to, either: provide a smooth solution, or a meaningful error message.

    Is it possible to catch this exception from the application? I would like to tell the user that he is missing that library, and depending on the OS suggest how can he install it.


    Regards,

    Jose Gómez.


    On Tuesday, February 12, 2013 1:09:32 PM UTC, Samuel Audet wrote:

    Samuel Audet

    unread,
    Feb 13, 2013, 8:15:33 AM2/13/13
    to jav...@googlegroups.com
    On 02/13/2013 05:29 AM, Jose G�mez wrote:
    > I know it is not right, but creating a link from the name of an older
    > version of the library to the new one quite often works, as it does in
    > this case.
    >
    > Anyway, we need to, either: provide a smooth solution, or a meaningful
    > error message.
    >
    > Is it possible to catch this exception from the application? I would
    > like to tell the user that he is missing that library, and depending on
    > the OS suggest how can he install it.

    Sure, just enclose Loader.load() calls in a
    try {
    Loader.load(...);
    } catch (UnsatisfiedLinkError e) {
    /* block, and do whatever you need here */
    }

    Samuel

    Jose Gómez

    unread,
    Feb 14, 2013, 4:47:58 PM2/14/13
    to jav...@googlegroups.com
    I just did that at the beginning of my main function, and it works perfectly. Thanks!

    Now at least I can present a human-readable error to the user: "The program cannot be started because a library is missing: " + substring-after-space(exception.getMessage())

    And I will also use it in order to check for the presence of libraries that I can consider optional, like FFmpeg.

    I think I'll wrap this in a class in order to request loading required and optional libraries, and in the first case display an error, while in the second case, set some flags which I can check later in my code.

    On Wednesday, February 13, 2013 1:15:33 PM UTC, Samuel Audet wrote:
    Reply all
    Reply to author
    Forward
    0 new messages