Hi,
I'm interesting in building libusbJava under Mac OSX. However, I'm having some problems, and would appreciate any help on this matter.
-- Mike
I have modified the build.xml file and the project.properties file.
Below is the project.properties file:
------------------------------------------------------------
############################
# common build properties #
############################
# folders
build.dir.src=src
build.dir.bin=bin
# filenames
build.lib.libusb=libusb.a
build.lib.libusbpp=libusbpp.a
build.shlib.srcname=LibusbJava.cpp
build.shlib.win.shlibname=LibusbJava.dll
build.shlib.linux.shlibname=libusbJava.so
build.shlib.mac.shlibname=libusbJava.so
build.test.srcname=LibusbTest
build.test.execname=LibusbTest
#####################################
# Windows specific build properties #
#####################################
build.win.compiler=g++
build.win.windres=windres
build.win.resource.rc=resource.rc
build.win.resource.obj=resource.o
####################################
# Linux specific build properties #
####################################
build.linux.compiler=g++
build.linux.includes=/usr/lib
####################################
# Mac specific build properties #
####################################
build.mac.compiler=g++
build.mac.includes=/usr/local/lib
build.mac.jni=/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
------------------------------------------------------------
and here are the additions I made to the build.xml file
Note: I inserted -dynamiclib, and -dynamiclib arguments because Mac OSX gcc
doesn't support the -shared argument, and I saw somewhere on the web that these
two arguments might work.
------------------------------------------------------------
<property name="version.mac" value="${version.major}.${version.minor}.${version.micro}" />
and <target name="macosx" depends="clean" description="--> Build $\{build.shlib.mac.shlibname\}"> <exec dir="." executable="$\{build.mac.compiler\}"> <\!-- for debugging --> <arg value="-v" /> <\!-- Mac OSX doesn't support -shared --> <arg value="-dynamiclib" /> <arg value="-Wl,-soname,$\{build.shlib.mac.shlibname\}" /> <arg value="-I$\{build.mac.includes\}" /> <\!-- couldn't find jni.h so added this --> <arg value="-I$\{build.mac.jni\}" /> <\!-- Mac OSX doesn't support -shared --> <arg value="-dynamiclib" /> <arg value="$\{build.shlib.srcname\}" /> <arg value="-o $\{build.shlib.mac.shlibname\}.$\{version.mac\}" /> <arg value="$\{build.mac.includes\}/$\{build.lib.libusb\}" /> <arg value="$\{build.mac.includes\}/$\{build.lib.libusbpp\}" /> </exec> </target>
------------------------------------------------------------
and below is the results of issuing the ant command
------------------------------------------------------------
sudo ant -verbose -debug macosx
Apache Ant version 1.6.5 compiled on April 11 2006
Apache Ant version 1.6.5 compiled on April 11 2006
Buildfile: build.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.5 in: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
Detected OS: Mac OS X
Adding reference: ant.ComponentHelper
Setting ro project property: ant.version -> Apache Ant version 1.6.5 compiled on April 11 2006
Setting ro project property: ant.file -> /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava/build.xml
Adding reference: ant.projectHelper
Adding reference: ant.parsing.context
Adding reference: ant.targets
parsing buildfile /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava/build.xml with URI = file:///Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava/build.xml
Setting ro project property: ant.project.name -> LibusbJava
Adding reference: LibusbJava
Setting ro project property: ant.file.LibusbJava -> /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava/build.xml
Project base dir set to: /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava
+Target:
Adding reference: buildfiles
+Target: clean
+Target: windows
+Target: linux
+Target: macosx
[property] Loading /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava/project.properties
Setting project property: build.win.resource.obj -> resource.o
Setting project property: build.test.execname -> LibusbTest
Setting project property: build.dir.bin -> bin
Setting project property: build.linux.compiler -> g++
Setting project property: build.mac.includes -> /usr/local/lib
Setting project property: build.test.srcname -> LibusbTest
Setting project property: build.lib.libusbpp -> libusbpp.a
Setting project property: build.shlib.mac.shlibname -> libusbJava.so
Setting project property: build.win.resource.rc -> resource.rc
Setting project property: build.mac.jni -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
Setting project property: build.mac.compiler -> g++
Setting project property: build.shlib.srcname -> LibusbJava.cpp
Setting project property: build.win.compiler -> g++
Setting project property: build.dir.src -> src
Setting project property: build.lib.libusb -> libusb.a
Setting project property: build.linux.includes -> /usr/lib
Setting project property: build.win.windres -> windres
Setting project property: build.shlib.linux.shlibname -> libusbJava.so
Setting project property: build.shlib.win.shlibname -> LibusbJava.dll
[property] Loading /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava/version.properties
Setting project property: version.micro -> 2
Setting project property: version.minor -> 4
Setting project property: version.nano -> 0
Setting project property: version.major -> 0
Setting project property: version.win.rc -> 0,4,2,0
Setting project property: version.win.str -> 0.4.2.0
Setting project property: version.linux -> 0.4.2
Setting project property: version.mac -> 0.4.2
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type sshexec
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type scp
Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend
Could not load a dependent class (junit/framework/Test) for type junit
Adding reference: buildfiles
Attempting to create object of type org.apache.tools.ant.helper.DefaultExecutor
Adding reference: ant.executor
Build sequence for target(s) `macosx' is [clean, macosx]
Complete build sequence is [clean, macosx, linux, windows, ]
clean:
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type sshexec
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type scp
Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend
Could not load a dependent class (junit/framework/Test) for type junit
fileset: Setup scanner in dir /Users/mike/Development/JavaProjects/LibUsbJavaProject/trunk/LibusbJava with patternSet{ includes: [**/*.o, **/*.dll, **/*.so.*] excludes: [] }
macosx:
[exec] Current OS is Mac OS X
[exec] Executing 'g++' with arguments:
[exec] '-v'
[exec] '-dynamiclib'
[exec] '-Wl,-soname,libusbJava.so'
[exec] '-I/usr/local/lib'
[exec] '-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers'
[exec] '-dylib'
[exec] 'LibusbJava.cpp'
[exec] '-o libusbJava.so.0.4.2'
[exec] '/usr/local/lib/libusb.a'
[exec] '/usr/local/lib/libusbpp.a'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
Execute:Java13CommandLauncher: Executing 'g++' with arguments:
'-v'
'-dynamiclib'
'-Wl,-soname,libusbJava.so'
'-I/usr/local/lib'
'-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers'
'-dylib'
'LibusbJava.cpp'
'-o libusbJava.so.0.4.2'
'/usr/local/lib/libusb.a'
'/usr/local/lib/libusbpp.a'
The ' characters around the executable and arguments are
not part of the command.
[exec] Using built-in specs.
[exec] Target: powerpc-apple-darwin8
[exec] Configured with: /private/var/tmp/gcc/gcc-5341.obj~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8
[exec] Thread model: posix
[exec] gcc version 4.0.1 (Apple Computer, Inc. build 5341)
[exec] /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/cc1plus -quiet -v -I/usr/local/lib -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers -D__DYNAMIC__ LibusbJava.cpp -fPIC -quiet -dumpbase LibusbJava.cpp -dylib -auxbase LibusbJava -version -D__private_extern__=extern -o /var/tmp//ccpHaxhO.s
[exec] ignoring nonexistent directory "/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../../powerpc-apple-darwin8/include"
[exec] #include "..." search starts here:
[exec] #include <...> search starts here:
[exec] /usr/local/lib
[exec] /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
[exec] /usr/include/c++/4.0.0
[exec] /usr/include/c++/4.0.0/powerpc-apple-darwin8
[exec] /usr/include/c++/4.0.0/backward
[exec] /usr/local/include
[exec] /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include
[exec] /usr/include
[exec] /System/Library/Frameworks
[exec] /Library/Frameworks
[exec] End of search list.
[exec] GNU C++ version 4.0.1 (Apple Computer, Inc. build 5341) (powerpc-apple-darwin8)
[exec] compiled by GNU C version 4.0.1 (Apple Computer, Inc. build 5341).
[exec] GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81920
[exec] Compiler executable checksum: 4f3dfc1e1dae2832661a538a73ff9412
[exec] as -arch ppc -o /var/tmp//cc6oL4mm.o /var/tmp//ccpHaxhO.s
[exec] /usr/bin/libtool -dynamic -arch_only ppc -noall_load -macosx_version_min 10.3 -multiply_defined suppress -weak_reference_mismatches non-weak -o libusbJava.so.0.4.2 -o a.out /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/crt3.o -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1 -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1 -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../.. -soname libusbJava.so /var/tmp//cc6oL4mm.o /usr/local/lib/libusb.a /usr/local/lib/libusbpp.a -lstdc++ -lgcc_s.10.4 -lgcc -lSystemStubs -lSystem
[exec] /usr/bin/libtool: unknown option character `o' in: -o libusbJava.so.0.4.2
[exec] Usage: /usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT]
[exec] Usage: /usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
[exec] Result: 1
BUILD SUCCESSFUL
Total time: 4 seconds
------------------------------------------------------------