我想将GDAL及其JAVA绑定打包到SWT插件中。 (P.S. GDAL使用swig生成Java绑定)
我拥有所有必需的本机库,并希望将它们打包到我的Eclipse插件中,让其他人使用它而无需在计算机上安装GDAL。
问题是JAVA绑定(或本机lib本身)将从 PATH (窗口)或 LD_LIBRARY_PATH (Linux)查找必要的本机库,而不是查找这些库在相对位置。此外,GDAL还将从环境变量 GDAL_DATA 中查找一些必要的地理定义数据。
如何解决这两个问题以制作便携式SWT插件? 1)包平台特定的本机库 2)一些环境变量查找
似乎eclipse无法在没有设置PATH的情况下解析依赖的lib。 Bundle-NativeCode(见下文)不起作用。
如果我尝试直接在我的插件中调用System.Library(“SomethingNotExist”); 然后我得到
java.lang.UnsatisfiedLinkError: no SomethingNotExist in java.library.path
如果我在插件中调用System.Library(“SomethingDoesExist”),那么我
java.lang.UnsatisfiedLinkError: SomethingDoesExist.dll: Can't find dependent libraries
插件中的文件结构
org.gdal/
+ src/
+ nativelib/
+ linux32/
+ ...
+ linux32/
+ ...
+ win32/
+ ...
+ win64/
+ ...
+ META-INF
+ MANIFEST.MF
+ gdal-data/
+ gdal.jar
+ build.properties
此插件的build.properties
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
gdal.jar,\
gdal-data/,\
nativelib/
此插件的清单
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
答案 0 :(得分:0)
关于Java中GDAL的环境问题
使用gdal.SetConfigOption
http://osgeo-org.1560.n6.nabble.com/gdal-dev-GDAL-DATA-td3744017.html
将GDAL_DATA设置为可以从插件包中读取的文件夹。
http://www.vogella.de/blog/2010/07/06/reading-resources-from-plugin/