-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Create single JNI shared library #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… that have been configured. Revise Java JNI shared library generation to produce one library instead of 5. This simplifies deployment. It requires that several functions that are generated for several modules be declared static. For Windows, correct the deletion the 'org' library during 'clean'; was dependent on a file named 'nul' that doesn't get created.
This fails at runtime on Travis-CI (and likely on Windows too) with
|
…ig/java/GNUmakefile to include all object modules.
Load library should be fixed now. The Linux shared JNI library still needs libgdal.so in the LD_LIBRARY_PATH. If the Windows build is without DLLBUILD defined, the final shared library will include gdal.lib, so gdal.dll is not needed. But then the static version of any external libraries are needed. |
re: 13268.1 check failed Is there a requirement for Swig version 1 to be supported? I can't even install it on my Linux system from the Ubuntu repository. The last Swig 1.3.40 release is from 2009. |
Ok, looking at the log more closely, I see that Swig 2.0.4 was used. There was a change somewhere between that release and the Swig 2.0.12 version I used to make the SWIG_JavaArrayXXX functions static. It's not noted in the release notes, but "Lib/java/arrays_java.i" in the Swig code was changed to make the functions static. For Swig 2.0.4, this can be fixed by adding "CFLAGS += -DSWIG_NOARRAYS" to swig/java/GNUmakefile and some similar change to makefile.vc, but that precludes the use of the Java array functions without additional work, should someone decide to use them in the futures. Suggestions? |
We could potentially drop the Java bindings on the precise_clang target (they are tested in the trusty_clang too) |
Or upgrade to at least Swig 2.0.5. The use of 'static' for SWIG_JavaArrayXXX was introduced in that version. I suppose putting in the macro SWIG_NOARRAYS isn't so bad. By the time someone changes the code to use any of those functions, the more recent versions of Swig will be in use. |
…rrayXXX routines, which are declared static by later versions of Swig
re: 13301.8 failed |
gdal/swig/java/GNUmakefile
Outdated
$(JAVA_MODULES): $(JAVA_OBJECTS) | ||
$(LINK) $(LDFLAGS) $^ $(CONFIG_LIBS) -o $@ $(LINK_EXTRAFLAGS) | ||
$(JAVA_MODULES): $(JAVA_OBJECTS) | ||
$(LINK) $(LDFLAGS) $^ $(GDAL_LIB) $(CONFIG_LIBS) -o $@ $(LINK_EXTRAFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is a good idea to incorporate libgdal in the java bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, do you think it will cause a problem? Personally, I prefer to have only one file to deal with. But, certainly, back out the change if you have strong feelings about it.
Note that if the Windows version is built with DLLBUILD undefined, this is what happens with the unmodified code base, with all of the referenced objects being included in each of the DLL's that are built.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well perhaps this makes sense on Windows, but this is less in the Unix philosophy to bundle everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let you decide.
My interest is upgrading the GDAL library included with Nasa's WorldWind. The copy of GDAL they are including is version 1.7.2. They have released copies of the JNI interface for multiple platforms with libgdal included in the JNI shared library. It seemed like a good idea to me, but for the life of me I can't see how they included the MrSID libraries in their DLL or .so shared libraries.
They also installed a custom loader. I have a parallel pull request outstanding with them (NASAWorldWind/WorldWindJava#146), but I left the libraries separate, thinking that if they were to be combined that should be part of GDAL.
Happy Holidays!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let you decide.
I'll prefer to not have libgdal incorporated in the libgdaljniall.so, at least not by default. If you can find a way of parameterizing it, why not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that last change meet with your approval?
…te regarding libgdal.a inclusion
Committed in trunk r41228. Thanks ! |
…patch by gbburkhardt, fixes OSGeo/gdal#286) git-svn-id: https://svn.osgeo.org/gdal/trunk/gdal@41228 f0d54148-0727-0410-94bb-9a71ac55c965
…patch by gbburkhardt, fixes #286) git-svn-id: https://svn.osgeo.org/gdal/trunk@41228 f0d54148-0727-0410-94bb-9a71ac55c965
sorry ladies but I have a problem. I've just upgraded GDAL to version 2.3.0 on my windows 10 machine. I use gradle for dependency management, so I've added It downloads a small jar that does not include any OS dependant libraries, so when I try to use it it look for the gdalalljni in my java.library.path, and it fails. Apparently in the newer distribution, that dll is not included anymore. I got my gdal package from: and installed the core. I think you have two options:
Thanks for great works. Fernando |
That binary distribution has the gdalalljni.dll file in the "bin\gdal\java" directory. Try including that directory in your "java.library.path". |
It doesn't look like the "gdal/swig/java/README.txt" file was merged to the main branch. Can that be done, or is another pull request needed? Would it be better to have the comments in the make files, too? |
I'm sorry but there is no java subdirectory in my gdal root directory. I've performed a clean install selecting a complete install but still I don't see anything. |
When the new single JNI library introduced in OSGeo#286, the Makefile was not fully updated to copy the new libraries from the .lib dir into the source directory for later copying during the install phase. This patch addresses that.
When the new single JNI library introduced in #286, the Makefile was not fully updated to copy the new libraries from the .lib dir into the source directory for later copying during the install phase. This patch addresses that.
For deployment, it's a little easier to have one shared library for the JNI interface, and maintenance is bit easier, too, if a binary distribution includes shared libraries for multiple platform. These changes to the makefiles in swig/java create a single library instead of five. I also prefer that all the GDAL code including external libraries be included in the single JNI library, to make sure that all required code is there and it's all compatible. That applies to the static library gdal.lib when it is produced for windows - all the external libraries should be included.
I also noticed that the Java code generated by Swig in the 'org' directory wasn't being deleted for the 'clean' target for Windows. The revised 'swig/java/makefile.vc' fixes that.