Discussion:
[Swig-devel] cross platform jar
s***@netcourrier.com
2015-11-05 16:45:00 UTC
Permalink
Hello,


We're currently developing a java application that needs the gdal library. This library use swig for java bindings.



We're facing a cross platform problem, I think that I misunderstood something... We are developing our application on a windows platform and deploy it on a linux platform. The gdal library is installed on window and linux. It works like a charm on windows as we use the swig jar delivered in the installer. But when we deploy our application on linux with this swig jar, it doesn't work... We have to switch on the linux version of the swig binding jar to make this work.



I suppose that the gdal library is not compiled with the same options on windows and on linux, so the swig jar is not the same and cause our problem...



Questions are :

- Is there any chance for this to work (i.e. having a single cross platform jar file)? In the Java world, having 2 different jars is not coherent and the toolset that we use is not designed to handle this.

- Can we compile the swig jar binding file to ignore non used C++ methods?



Thanks for any reply,



Sebastien
Gareth Francis
2015-11-05 17:50:47 UTC
Permalink
Past the platform specific code in gcore I don't know of any real
differences, or anything that should affect swig.
Have you done a diff between the windows and linux swig wrappers? (Should
be something like gdal_wrap.cxx)

The only difference in the jars is likely in the section of code that loads
the native library, if you don't have to do it yourself in the application..
I think the gdal developers are fairly active, so it's worth sending the
question their direction aswell.

If you want to exclude parts of the api you'll need to modify the swig
files. See %ignore in the swig docs.
Post by s***@netcourrier.com
Hello,
We're currently developing a java application that needs the gdal library.
This library use swig for java bindings.
We're facing a cross platform problem, I think that I misunderstood
something... We are developing our application on a windows platform and
deploy it on a linux platform. The gdal library is installed on window and
linux. It works like a charm on windows as we use the swig jar delivered in
the installer. But when we deploy our application on linux with this swig
jar, it doesn't work... We have to switch on the linux version of the swig
binding jar to make this work.
I suppose that the gdal library is not compiled with the same options on
windows and on linux, so the swig jar is not the same and cause our
problem...
- Is there any chance for this to work (i.e. having a single cross
platform jar file)? In the Java world, having 2 different jars is not
coherent and the toolset that we use is not designed to handle this.
- Can we compile the swig jar binding file to ignore non used C++ methods?
Thanks for any reply,
Sebastien
------------------------------------------------------------------------------
_______________________________________________
Swig-devel mailing list
https://lists.sourceforge.net/lists/listinfo/swig-devel
--
--------------------
Gareth Francis
www.gfrancisdev.co.uk
s***@netcourrier.com
2015-11-06 10:39:16 UTC
Permalink
Thank you for your reply.
By reading your reply, I understand that it is not possible to have a common gdal.jar between windows and linux as the native library loading code is inside the swig jar ? Is that right ?

If I am correct, what are the alternatives ? Load the swig jar dynamically in my java code ?



I already post this question on the gdal dev list but no one replies me...

---- Original message ----
From: Gareth Francis
To: ***@netcourrier.com
Subject: Re: [Swig-devel] cross platform jar
Date: 05/11/2015 18:50:47 CET
Cc: swig-***@lists.sourceforge.net

Past the platform specific code in gcore I don't know of any real differences, or anything that should affect swig.
Have you done a diff between the windows and linux swig wrappers? (Should be something like gdal_wrap.cxx)



The only difference in the jars is likely in the section of code that loads the native library, if you don't have to do it yourself in the application..


I think the gdal developers are fairly active, so it's worth sending the question their direction aswell.



If you want to exclude parts of the api you'll need to modify the swig files. See %ignore in the swig docs.





On 5 November 2015 at 16:45, <***@netcourrier.com> wrote:

Hello,


We're currently developing a java application that needs the gdal library. This library use swig for java bindings.



We're facing a cross platform problem, I think that I misunderstood something... We are developing our application on a windows platform and deploy it on a linux platform. The gdal library is installed on window and linux. It works like a charm on windows as we use the swig jar delivered in the installer. But when we deploy our application on linux with this swig jar, it doesn't work... We have to switch on the linux version of the swig binding jar to make this work.



I suppose that the gdal library is not compiled with the same options on windows and on linux, so the swig jar is not the same and cause our problem...



Questions are :

- Is there any chance for this to work (i.e. having a single cross platform jar file)? In the Java world, having 2 different jars is not coherent and the toolset that we use is not designed to handle this.

- Can we compile the swig jar binding file to ignore non used C++ methods?



Thanks for any reply,



Sebastien


------------------------------------------------------------------------------

_______________________________________________
Swig-devel mailing list
Swig-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-devel
--
--------------------
Gareth Francis
www.gfrancisdev.co.uk
Gareth Francis
2015-11-06 11:15:44 UTC
Permalink
It's a possible place there's a problem. I haven't had the time to build
the swig bindings myself, but do have a copy of the source.

It looks like the jar will load the native libraries itself
(gdal/swig/include/java/gdal_java.i:
private static boolean available = false;

static {
try {
System.loadLibrary("gdaljni");
available = true;

if (gdal.HasThreadSupport() == 0)
{
System.err.println("WARNING : GDAL should be compiled with thread
support for safe execution in Java.");
}

} catch (UnsatisfiedLinkError e) {
available = false;
System.err.println("Native library load failed.");
System.err.println(e);
}
}

public static boolean isAvailable() {
return available;

So as long as it's called 'gdaljni.dll' or 'libgdaljni.so' it should load
the library correctly.
There should also be an obvious message logged to stderr if it fails to
load.

I can't see anything in gdal that would be system specific, as far as the
java interface goes, so your problems are more likely down to the system
configuration.

Can you get the gdal java applications to work? (gdal/swig/java/apps)
Post by s***@netcourrier.com
Thank you for your reply.
By reading your reply, I understand that it is not possible to have a
common gdal.jar between windows and linux as the native library loading
code is inside the swig jar ? Is that right ?
If I am correct, what are the alternatives ? Load the swig jar dynamically
in my java code ?
I already post this question on the gdal dev list but no one replies me...
---- Original message ----
From: Gareth Francis
Subject: Re: [Swig-devel] cross platform jar
Date: 05/11/2015 18:50:47 CET
Past the platform specific code in gcore I don't know of any real
differences, or anything that should affect swig.
Have you done a diff between the windows and linux swig wrappers? (Should
be something like gdal_wrap.cxx)
The only difference in the jars is likely in the section of code that
loads the native library, if you don't have to do it yourself in the
application..
I think the gdal developers are fairly active, so it's worth sending the
question their direction aswell.
If you want to exclude parts of the api you'll need to modify the swig
files. See %ignore in the swig docs.
Post by s***@netcourrier.com
Hello,
We're currently developing a java application that needs the gdal
library. This library use swig for java bindings.
We're facing a cross platform problem, I think that I misunderstood
something... We are developing our application on a windows platform and
deploy it on a linux platform. The gdal library is installed on window and
linux. It works like a charm on windows as we use the swig jar delivered in
the installer. But when we deploy our application on linux with this swig
jar, it doesn't work... We have to switch on the linux version of the swig
binding jar to make this work.
I suppose that the gdal library is not compiled with the same options on
windows and on linux, so the swig jar is not the same and cause our
problem...
- Is there any chance for this to work (i.e. having a single cross
platform jar file)? In the Java world, having 2 different jars is not
coherent and the toolset that we use is not designed to handle this.
- Can we compile the swig jar binding file to ignore non used C++ methods?
Thanks for any reply,
Sebastien
------------------------------------------------------------------------------
_______________________________________________
Swig-devel mailing list
https://lists.sourceforge.net/lists/listinfo/swig-devel
--
--------------------
Gareth Francis
www.gfrancisdev.co.uk
------------------------------------------------------------------------------
_______________________________________________
Swig-devel mailing list
https://lists.sourceforge.net/lists/listinfo/swig-devel
--
--------------------
Gareth Francis
www.gfrancisdev.co.uk
William S Fulton
2015-11-25 20:04:26 UTC
Permalink
Post by s***@netcourrier.com
Hello,
We're currently developing a java application that needs the gdal library.
This library use swig for java bindings.
We're facing a cross platform problem, I think that I misunderstood
something... We are developing our application on a windows platform and
deploy it on a linux platform. The gdal library is installed on window and
linux. It works like a charm on windows as we use the swig jar delivered in
the installer. But when we deploy our application on linux with this swig
jar, it doesn't work... We have to switch on the linux version of the swig
binding jar to make this work.
I suppose that the gdal library is not compiled with the same options on
windows and on linux, so the swig jar is not the same and cause our
problem...
- Is there any chance for this to work (i.e. having a single cross
platform jar file)? In the Java world, having 2 different jars is not
coherent and the toolset that we use is not designed to handle this.
SWIG should produce identical code when generated on all platforms. There
is nothing in the Java layer that is platform specific so you can use just
one jar file on all platforms. There is a very small amount of
platform/compiler specific code within C macros in the generated code.

- Can we compile the swig jar binding file to ignore non used C++ methods?
Use %ignore.

William

Loading...