问题描述
我想将及其JAVA绑定程序打包成SWT插件。
(PS GDAL使用swig生成Java绑定)
我拥有所有必需的本机库,并希望将它们打包到我的Eclipse插件中,让其他人使用它,而不在他们的计算机上安装GDAL。
问题是JAVA Binding(或本机lib本身)将从 PATH (Window)或 LD_LIBRARY_PATH (Linux),而不是在相对位置查找这些库。此外,GDAL还将从环境变量 GDAL_DATA 中查找一些必要的地理定义数据。
如何解决这两个问题一个便携式SWT插件?
1)包平台特定的本地库
2)一些环境变量查询
似乎eclipse无法解析依赖的库,而不需要设置PATH 。
Bundle-NativeCode(见下文)不起作用。
如果我尝试直接在我的插件中调用System.Library(SomethingNotExist);
然后我得到
java.lang.UnsatisfiedLinkError:no java.library.path中的SomethingNotExist
如果我在我的插件中调用System.Library(SomethingDoesExist),那么我得到
java.lang.UnsatisfiedLinkError:SomethingDoesExist.dll:找不到依赖库
我的插件中的文件结构
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 /
此插件的清单
清单版本: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 /
导出包:org.gdal,
org.gdal.gdal ,
org.gdal.gdalconst,
org.gdal.ogr,
org.gdal.osr
Bundle-RequiredExecutionEnvironment:JavaSE-1.6
$ c $对于Java中的GDAL的环境问题,c>
/ p>
使用gdal.SetConfigOption
将GDAL_DATA设置为可以从插件包中读取的文件夹。
I want to package GDAL and its JAVA binding into a SWT plug-in.(P.S. GDAL use swig to generate Java binding)
I have all necessary native libraries and want to pack them into my Eclipse plug-in to let other people use it without installing GDAL on their computer.
The problem is that the JAVA Binding (or native lib itself) will lookup necessary native libraries from PATH (Window) or LD_LIBRARY_PATH (Linux) instead looking up those libs in a relative location. Furthermore, GDAL will look up some necessary geo definition data from the environment variable GDAL_DATA as well.
How can I solve those two problems to make a portable SWT plug-in?1) package platform specific native libs2) some environment variable look-up
It seems that eclipse cannot resolve dependent libs without having PATH set.Bundle-NativeCode (see below) did 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, then I get
java.lang.UnsatisfiedLinkError: SomethingDoesExist.dll: Can't find dependent libraries
The file structure in my plug-in
org.gdal/
+ src/
+ nativelib/
+ linux32/
+ ...
+ linux32/
+ ...
+ win32/
+ ...
+ win64/
+ ...
+ META-INF
+ MANIFEST.MF
+ gdal-data/
+ gdal.jar
+ build.properties
The build.properties for this Plug-in
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
gdal.jar,\
gdal-data/,\
nativelib/
The Manifest for this Plug-in
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
for the environment issue of GDAL in Java
use gdal.SetConfigOption
http://osgeo-org.1560.n6.nabble.com/gdal-dev-GDAL-DATA-td3744017.html
to set GDAL_DATA with the folder which can be read from a plugin bundle.
http://www.vogella.de/blog/2010/07/06/reading-resources-from-plugin/
这篇关于在SWT插件中打包GDAL JAVA绑定和本地库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!