[brailleblaster] Re: Placement of Native Librraries

  • From: "John J. Boyer" <john.boyer@xxxxxxxxxxxxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Mon, 18 Jul 2011 15:55:57 -0500

Michael,

Where are you getting this information on JNA? Could you provide thr 
URL? 

The libraries are too big to include all the different ones in a single 
jar. This is particularly true of libxml2. 

I am pplanning to make a different version of the dist subdirectory for 
each platform. This will be zipped, so the user need only download it 
and unzip it in the proper place. For Windows we might make it a 
self-extracting exe file.

Also for Windows, I am statically linking libxml2 with liblouisutdml 
They distribute a win32 subdirectory, but it is out of date and would 
only make 32-bit binaries. It also has a lot of stuff carried over from 
Linux that makes no sense in the Windows environment.

I am checking to see if Linux will find the libraries if they are in the 
same directory as brailleblaster.jar When the Mac which is being loaned 
to me arrives I will see if this also works there. Alex can then make 
the app bundle.

John

On Mon, Jul 18, 2011 at 09:18:51PM +0100, Michael Whapples wrote:
> One response I would make is that you say including the libraries in the JAR 
> file means that you would need to produce a JAR for each supported platform, 
> not true. I will refer to my example of JNA again, they have one JAR file 
> which contains all libraries required for each platform and at runtime they 
> determine which platform the application is being run on and extract the 
> correct library files. However this does mean that the JAR file is larger 
> than any single user may need as it contains the libraries for the platforms 
> which the user does not use. If the libraries are only small then this is not 
> an issue, however if they are large it may be.
> 
> Also you indicate that if separate JARs needed to be created for each 
> platform this would be more difficult than if the libraries were separate. I 
> don't know why, surely the build script (possibly an ant build file) could 
> manage this for you and all it might require is running a build/package task 
> on each platform. Possibly if you had the binaries all built then this may be 
> able to be done on one platform (a release task which could package for all 
> supported platforms). Anyway you will need to construct archive files for 
> each platform anyway for people to download, I cannot imagine the final 
> product being acceptable if the download instructions say download this, 
> that, that, that for your platform, and the other. I would have thought 
> people should only need to download one archive (eg. zip) file. A JAR is just 
> another archive file!
> 
> Again JNA may provide some useful examples, they have an ant built file to 
> package JNA, that might give you ideas on the packaging stuff I was saying 
> about.
> 
> Michael Whapples
> On 18 Jul 2011, at 20:13, John J. Boyer wrote:
> 
> > Thanks, Michael and Chris. I'm trying to find the code that SWT uses to 
> > extract native libraries. It must be in the internals package. I've 
> > been told that -Djava.library.path doesn't work in Windows, and it 
> > doesn't, as far as I can tell. I've been putting the native libraries in 
> > dist/native/lib but then Windows can't find the dependencies. If i put 
> > them in the same directory as brailleblaster.jar and this is the curent 
> > directory there is no problem, but it's not very neat. I don't know if 
> > this will work under Linux and Mac.
> > 
> > Come to think of it, putting the native libraries in the jar file is not 
> > a good idea for a cross-platform application. It would mean having to 
> > distribute a separate jar file for each platform rather than just 
> > separate native libraries.
> > 
> > Thanks,
> > John
> > 
> > On Sat, Jul 16, 2011 at 09:03:58AM -0700, Chris von See wrote:
> >> Once the native library is extracted to the local file system you can  
> >> use System.load() to load it from your temp location, or you can place  
> >> it into a location defined by the "java.library.path" environment  
> >> variable and use System.loadLibrary() to load it from there.
> >> 
> >> Google also turned up a Sourceforge project called One-JAR 
> >> (http://one-jar.sourceforge.net/ ) which claims to take care of this for 
> >> you.  I've not used this  personally.
> >> 
> >> Google also turned up the following as part of an answer to this  
> >> question - I see lots of references to doing this with applets, but  
> >> not with desktop apps:
> >> 
> >> "SWT puts the necessary native DLLs into a JAR. Search for  
> >> "org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar" for an example.   
> >> The DLLs must be in the root of the JAR, the JAR must be signed and  
> >> the DLL must appear with checksum in the META-INF/MANIFEST.MF for the  
> >> VM to pick them up."
> >> 
> >> 
> >> Cheers
> >> Chris
> >> 
> >> 
> >> 
> >> On Jul 16, 2011, at 8:46 AM, Michael Whapples wrote:
> >> 
> >>> How SWT and JNA include binaries in a JAR file (NOTE: they use  
> >>> different code, JNA manages to include all architectures in one jar  
> >>> file): Basically they have the binary library files somewhere within  
> >>> the JAR file, and then when the classes which will need the  
> >>> libraries are loaded, the binary files are extracted to a temporary  
> >>> location outside the JAR file and then the JVM uses the libraries  
> >>> from that location. I think both JNA and SWT have code which tries  
> >>> to clean up the system when the classes are no longer being used (I  
> >>> don't know exactly where they may do this but in a finalizer seems  
> >>> reasonable to me).
> >>> 
> >>> I understand the reason that the library files need to be extracted  
> >>> first is due to a platform restriction which prevents loading of  
> >>> dynamic libraries from an archive file (certainly the case for  
> >>> windows, don't know about Linux and Mac, but as you have to do this  
> >>> for windows you may as well do it for the other platforms).
> >>> 
> >>> Also it might be worth remembering the options/system properties  
> >>> which allow specifying where the JVM should look for dynamic  
> >>> libraries. I don't have this information to hand but probably could  
> >>> find it out very easily.
> >>> 
> >>> Michael Whapples
> >>> On 16 Jul 2011, at 16:10, John J. Boyer wrote:
> >>> 
> >>>> There seems to be a platform difference in where liblouis-2 and
> >>>> libluisutdml should be placed. I have them in
> >>>> brailleblaster/dist/native/lib which is neat. Windows has trouble
> >>>> finding them there. The solution I would like to use is to place them
> >>>> inside brailleblaster.jar just as the swt native libraries are placed
> >>>> inside swt.jar. But I can't find out how to tell the JVM to look for
> >>>> them there. I've looked at the swt manifest to no avail. Any  
> >>>> information
> >>>> will be apprediated.
> >>>> 
> >>>> Thanks,
> >>>> John
> >>>> 
> >>>> -- 
> >>>> John J. Boyer; President, Chief Software Developer
> >>>> Abilitiessoft, Inc.
> >>>> http://www.abilitiessoft.com
> >>>> Madison, Wisconsin USA
> >>>> Developing software for people with disabilities
> >>>> 
> >>>> 
> >>> 
> >>> 
> >> 
> > 
> > -- 
> > John J. Boyer; President, Chief Software Developer
> > Abilitiessoft, Inc.
> > http://www.abilitiessoft.com
> > Madison, Wisconsin USA
> > Developing software for people with disabilities
> > 
> > 
> 

-- 
John J. Boyer; President, Chief Software Developer
Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities


Other related posts: