UnsatisfiedLinkError caused by org.gdal.ogr.ogrJNI.GetDriverCount()

不羁的心 提交于 2020-01-15 07:48:11

问题


I am developing in Java on Windows 7 with Eclipse (Luna).

I am using gdal for some ogr processes and running the application from eclipse is fine, but running from command line on the same machine is running into problems.

and I get the following:

Caused by: java.lang.UnsatisfiedLinkError: org.gdal.ogr.ogrJNI.GetDriverCount()I
    at org.gdal.ogr.ogrJNI.GetDriverCount(Native Method)
    at org.gdal.ogr.ogr.GetDriverCount(ogr.java:170)

I've added all of the directories under gdal that contain dlls and jars to both the CLASSPATH and PATH environmental.

I thought it might be the libraries, but I am using the deployment location in the paths, which works in eclipse.

In the eclipse project's .classpath file I noticed that the gdal reference has an attribute called CLASSPATH_ATTR_LIBRARY_PATH_ENTRY, this links to the gdal\dll directory, but I have already included that in the paths:

<classpathentry exported="true" kind="lib" path="dependencies/gdal/bin/gdal/java/gdal.jar">
    <attributes>
        <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="dependencies/gdal/dll"/>
    </attributes>
</classpathentry>

This is the only difference I can see. How do you replicate this on a windows machine or is that handled by the CLASSPATH and PATH?

Do I need to reference the individual dlls? I have tried the 4 that normally go with gdal.jar, but that doesnt change the error that I am getting.


回答1:


I found this article / Post: http://sandbox.idre.ucla.edu/sandbox/tutorial/installing-gdal-for-windows

It talks about setting up GDAL for windows and is a lot more straight forward than the spiders web of includes and references I had.

I took all the references to gdal off the ClassPath and Path.

I then added only the link to the gdal/bin/gdal/java/gdal.jar on the ClassPath and a link to gdal/dll directory on the Path. That is it... that is all you need to do...

There are mentions in the post about GDAL_DATA and GDAL_DRIVERS, I didnt need those, but you could add those to be safe.

update GDAL_DATA is needed, just reference gdal/bin/gdal_data iirc

I can only deduce that Eclipse doesnt use the classpath so the extra references I put on the ClassPath were just confusing matters.




回答2:


I downloaded binaries from

https://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries

Since the binaries were build with MSVC 2017 x64 I had to install the

Microsoft Visual C++ 2017 Redistributeable

On my Windows machine to solve java.lang.UnsatisfiedLinkError.

My older Gdal Version 2.4.0 worked with already existing Microsoft Visual C++ 2010 Redistributeable



来源:https://stackoverflow.com/questions/32573954/unsatisfiedlinkerror-caused-by-org-gdal-ogr-ogrjni-getdrivercount

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!