GDAL JAVA package Binding and native library in SWT plugin

I want to pack GDAL and its JAVA binding to the SWT plugin. (PS GDAL uses swig to generate Java bindings)

I have all the necessary native libraries and you want to pack them into your Eclipse plug-in so that other people can use it without installing GDAL on their computer.

The problem is that JAVA Binding (or its own lib) will look for the necessary native libraries from PATH (Window) or LD_LIBRARY_PATH (Linux) instead of looking for these libraries in a relative location. In addition, GDAL will look for some necessary geo-information from the GDAL_DATA environment variable .

How can I solve these two problems to make a portable SWT module? 1) platform-specific platform 2) viewing environment variables

It seems that eclipse cannot resolve dependent libraries without installing PATH. Bundle-NativeCode (see below) does not work.

If I try to directly call System.Library ("SomethingNotExist") in my plugin; then i get

java.lang.UnsatisfiedLinkError: no SomethingNotExist in java.library.path 

If I call System.Library ("SomethingDoesExist") in my plugin, I get

 java.lang.UnsatisfiedLinkError: SomethingDoesExist.dll: Can't find dependent libraries 

File structure in my plugin

 org.gdal/ + src/ + nativelib/ + linux32/ + ... + linux32/ + ... + win32/ + ... + win64/ + ... + META-INF + MANIFEST.MF + gdal-data/ + gdal.jar + build.properties 

Build.properties properties for this plug-in

 source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ gdal.jar,\ gdal-data/,\ nativelib/ 

Manifest for this plugin

 Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: GDAL Bundle-SymbolicName: org.gdal Bundle-Version: 1.8.1 Bundle-NativeCode: nativelib/linux32/libgdal.so; nativelib/linux32/libgdalconstjni.so; nativelib/linux32/libgdaljni.so; nativelib/linux32/libogrjni.so; nativelib/linux32/libosrjni.so; osname=Linux; processor=x86, nativelib/linux64/libgdal.so; nativelib/linux64/libgdalconstjni.so; nativelib/linux64/libgdaljni.so; nativelib/linux64/libogrjni.so; nativelib/linux64/libosrjni.so; osname=Linux; processor=x86_64, nativelib/win32/gdal18.dll; nativelib/win32/gdalconstjni.dll; nativelib/win32/gdaljni.dll; nativelib/win32/geos_c.dll; nativelib/win32/iconv.dll; nativelib/win32/libcurl.dll; nativelib/win32/libeay32.dll; nativelib/win32/libexpat.dll; nativelib/win32/libmysql.dll; nativelib/win32/libpq.dll; nativelib/win32/libxml2.dll; nativelib/win32/ogrjni.dll; nativelib/win32/openjpeg.dll; nativelib/win32/osrjni.dll; nativelib/win32/pdflib.dll; nativelib/win32/proj.dll; nativelib/win32/spatialite.dll; nativelib/win32/sqlite3.dll; nativelib/win32/ssleay32.dll; nativelib/win32/xerces-c_2_8.dll; nativelib/win32/zlib1.dll; osname=win32; processor=x86, nativelib/win64/ogrjni.dll; nativelib/win64/gdal18.dll; nativelib/win64/xerces-c_2_8.dll; nativelib/win64/libexpat.dll; nativelib/win64/libpq.dll; nativelib/win64/spatialite.dll; nativelib/win64/libmysql.dll; nativelib/win64/geos_c.dll; nativelib/win64/libcurl.dll; nativelib/win64/openjpeg.dll; nativelib/win64/iconv.dll; nativelib/win64/libeay32.dll; nativelib/win64/gdaljni.dll; nativelib/win64/osrjni.dll; nativelib/win64/gdalconstjni.dll; nativelib/win64/libxml2.dll; nativelib/win64/pdflib.dll; nativelib/win64/proj.dll; nativelib/win64/sqlite3.dll; nativelib/win64/ssleay32.dll; nativelib/win64/zlib1.dll; osname=win32; processor=x86_64 Bundle-ClassPath: gdal.jar, ., gdal-data/ Export-Package: org.gdal, org.gdal.gdal, org.gdal.gdalconst, org.gdal.ogr, org.gdal.osr Bundle-RequiredExecutionEnvironment: JavaSE-1.6 

+6
source share
1 answer

for a GDAL environment issue in a Java environment

use gdal.SetConfigOption

http://osgeo-org.1560.n6.nabble.com/gdal-dev-GDAL-DATA-td3744017.html

set GDAL_DATA with a folder that can be read from the plugin package.

http://www.vogella.de/blog/2010/07/06/reading-resources-from-plugin/

0
source

Source: https://habr.com/ru/post/904544/


All Articles