Menu

Linux compilation

Help
thys
2007-04-16
2012-12-06
  • thys

    thys - 2007-04-16

    Hi,

    For some reason I'm unable to compile LibusbJava on my Ubuntu edgy laptop. I've retrieved the whole project (all tags and trunk) and then run ant linux:
    The output follows:

    thys@thys-laptop:~/libusbjava/trunk/LibusbJava$ ant -v linux
    Apache Ant version 1.6.5 compiled on July 5 2006
    Buildfile: build.xml
    Detected Java version: 1.5 in: /usr/lib/jvm/java-6-sun-1.6.0.00/jre
    Detected OS: Linux
    parsing buildfile /home/thys/libusbjava/trunk/LibusbJava/build.xml with URI = file:///home/thys/libusbjava/trunk/LibusbJava/build.xml
    Project base dir set to: /home/thys/libusbjava/trunk/LibusbJava
    [property] Loading /home/thys/libusbjava/trunk/LibusbJava/project.properties
    [property] Loading /home/thys/libusbjava/trunk/LibusbJava/version.properties
    Build sequence for target(s) `linux' is [clean, linux]
    Complete build sequence is [clean, linux, windows, mac, ]

    clean:

    linux:
         [exec] Current OS is Linux
         [exec] Executing 'g++' with arguments:
         [exec] '-shared'
         [exec] '-Wl,-soname,libusbJava.so'
         [exec] '-I/usr/lib'
         [exec] '-shared'
         [exec] 'LibusbJava.cpp'
         [exec] '-olibusbJava.so.0.2.0'
         [exec] '/usr/lib/libusb.a'
         [exec] '/usr/lib/libusbpp.a'
         [exec]
         [exec] The ' characters around the executable and arguments are
         [exec] not part of the command.
         [exec] LibusbJava.cpp:10:17: error: jni.h: No such file or directory

    For some reason the header files cannot be found. I've tried all sorts of includes with the -I option in the build.xm and project.properties files to no avail.

    my java home:
    echo $JAVA_HOME
    /usr/lib/jvm/java-6-sun-1.6.0.00

    The jni.h file is located in the HOME as expected:
    /usr/lib/jvm/java-6-sun-1.6.0.00/include/jni.h

    I'm missing something obvious about ant but can't seem to get around the problem.

    I had to resort to compiling on the command line:

    g++ -shared -Wl,-soname,libusbJava.so -I/usr/lib -I/usr/lib/jvm/java-6-sun-1.6.0.00/include  -I/usr/lib/jvm/java-6-sun-1.6.0.00/include/linux -shared LibusbJava.cpp -olibusbJava.so.0.2.0 /usr/lib/libusb.a /usr/lib/libusbpp.a

    Any ideas will be appreciated.
    Thanks and regards

     
    • andi

      andi - 2007-04-19

      Hi

      I added two more include path properties to the file 'project.properties' and added the paths to the exec call as -I argument.

      So the ant target looks like (notice the build.linux.includes2 and 3):

          <target name="linux" depends="clean" description="--> Build ${build.shlib.linux.shlibname}">
              <exec dir="." executable="${build.linux.compiler}">
                  <arg value="-shared" />
                  <arg value="-Wl,-soname,${build.shlib.linux.shlibname}" />
                  <arg value="-I${build.linux.includes}" />
                  <arg value="-I${build.linux.includes2}" />
                  <arg value="-I${build.linux.includes3}" />
                  <arg value="-shared" />
                  <arg value="${build.shlib.srcname}" />
                  <arg value="-o${build.shlib.linux.shlibname}.${version.linux}" />
                  <arg value="${build.linux.includes}/${build.lib.libusb}" />
                  <arg value="${build.linux.includes}/${build.lib.libusbpp}" />
              </exec>
          </target>

      I had to add the path /usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/include when using gcj (on ubuntu) and the two paths /usr/lib/jvm/java-6-sun-1.6.0.00/include and /usr/lib/jvm/java-6-sun-1.6.0.00/include/linux when using Sun jdk 6

      But you've taken the right approach and tried the command on the command line first. If that works, there's no reason why it shouldn't work with ant.

      The updated version is in the trunk. If it doesn't work for you, please send me a mail.

      Regards, Andi

       

Log in to post a comment.

MongoDB Logo MongoDB