Menu

#69 java swig: liblibjyarp.so?

closed-fixed
nobody
None
5
2010-09-22
2009-12-09
kaouete
No

Hello,

If I compile the java swig library with the following command:
cmake . -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCREATE_PYTHON=TRUE -DCREATE_JAVA=TRUE
make

I get a file named liblibjyarp.so instead of libjyarp.so!

Also there is no way to install it and to have a jar file with the generated java file.
It would be cool to have the .so file in the jar also, I think this can be done…

Discussion

  • Paul Fitzpatrick

    Hi Kaouete, thanks for reporting this. What OS, CMake, and Swig versions are you using? If you look in example/swig/CMakeLists.txt, in the area within IF(CREATE_JAVA)... ENDIF(CREATE_JAVA) you'll see there is a little bit of logic that tries to pick a target name with or without the "lib" prefix depending on the platform. This logic will need to be extended, I guess, for your situation.
    Noone has added an install target for the java wrappers yet. You can see examples of INSTALL lines in the CMakeLists.txt for other languages, in case it inspires you to figure out a patch :-).

     
  • kaouete

    kaouete - 2009-12-09

    Hello,

    I am using 2.8.0, Swig 1.3.40 on Archlinux.

    At least for the version I have, I noticed that:
    In the source of the cmake swig module, there is this comment:
    # In java you want:
    # System.loadLibrary("LIBRARY");
    # then JNI will look for a library whose name is platform dependent, namely
    # MacOS : libLIBRARY.jnilib
    # Windows: LIBRARY.dll
    # Linux : libLIBRARY.so

    It looks like to me that swig handles the naming, so maybe you should let it do it and just use jyarp as module name.
    (and anyway, cmake does add .jnilib at the end of the module name when necessary).

     
  • kaouete

    kaouete - 2009-12-09

    So here is a proposition for installing jyarp:

    1) Choose better package names for the generated files AND the examples (for example it.liralab.eris.yarp or maybe with robotcub somewhere in the name) to avoid conflicts.
    2) package everything in a jar file without a main class (or you can make one jar only with the yarp common classes, and one per examples. To run them one will need to add the yarp one to the classpath).
    3) for the library thing, take a look at this http://nizzoli.net/2007/06/06/jar-jni-dll/ that explains how to exploit it, to me it looks like a not too bad solution…

    For the point 3, it is not really your problem, maybe you can just provide the jar without the library since it will be complex to make it work for every platform, it is more the problem of the user of yarp…

    I hope it helps, I don't have a the time to do it myself but I can do tests if you need me to :)
    Anyway, thanks for your help on this!

     
  • Paul Fitzpatrick

    For the .so naming issue (liblibjyarp.so), as of cmake 2.6-4 and swig 1.3.39, the code as is generates libjyarp.so. I would guess that the SWIG helper methods in cmake 2.8, which you are using, have been improved to insert a lib on UNIX style systems. If that is the case, we need to put in a conditional (we need to support cmake back to at least 2.4). It will take a little work to figure out the right conditional.
    Thanks for your suggestions for better Java packaging, and offer of testing. I'll advertise the suggestions on our mailing list and see if any of the Java users has time for it.

     
  • kaouete

    kaouete - 2009-12-09

    I think there is no version between 2.6.4 and 2.8, so for this it is easy :)
    I tried with swig 1.3.39 and the problem was also present, so I guess we only need to check for the cmake version!

     
  • Klaus

    Klaus - 2010-08-13

    By the way, is there a combination of versions for swig, cmake. yarp, etc that should surely work? A combination that has worked before for instance?
    tnx :D

     
  • Klaus

    Klaus - 2010-09-22

    There are new instructions at the site:
    http://eris.liralab.it/wiki/YARP_and_Java
    It solved my problem here. ;)

     
  • Paul Fitzpatrick

    • status: open --> closed-fixed