[Mono-dev] gdal/mono/linux; Native bindings, PInvoke, and tracking TypeLoader exceptions

fevans fevans at harris.com
Tue Jun 3 08:59:28 EDT 2008


First I want to express how impressed I am with how well mono performs (both
speed and stability). 


I'm trying to get native bindings working for gdal 1.5.1  (or any version of
gdal) in Linux.  If anyone has knowledge of gdal/mono/linux bindings that
would be great.  

If not, then I suppose a general discussion of native bindings is the next
step.  I'm outside my comfort zone, and struggling to even phrase the
question. But here are my observations. When I compile gdal in linux it
creates libraries and executables such as: 

gdalconst_csharp.dll
gdal_csharp.dll
ogr_csharp.dll
osr_csharp.dll
GDALInfo.exe

So when I run the command 'mono GDALInfo.exe' it returns a usage statement.
no errors. But when I run 'mono GDALinfo.exe foo.tif', I get a type-loader
exception.

===================
ANALYSIS
===================
Each library has a dllmap config mapping. For anyone who is interested in
getting gdal to work in mono/linux I believe that the dllmap  generated by
the GNUMakefile has an error.  The build process generates the following...
<dllmap dll="gdal_wrap" target="libgdalcsharp.la" >

But this is missing the closing "/" for the Xml tag, so it should look like
this.
<dllmap dll="gdal_wrap" target="libgdalcsharp.la" />

============================
?WHAT's MISSING?
============================
The build also creates gdal_wrap.lo, ogr_wrap.lo, etc. But it doesn't
produce a .so file for these, it doesn't produce a gdal_wrap.dll or a
dllmap. I'm pretty sure this is a problem, because those are the libraries
which contain the native bindings. At least, they do in Windows.

I tried creating gdal_wrap.so
gcc -shared -Wl,-soname,libgdal_wrap.so.1 -o libgdal_wrap.so.1.0.1 
gdal_wrap.o

It didn't help. 

I ran the command with 'mono -verbose'. See attached file.
http://www.nabble.com/file/p17622978/output3.txt output3.txt 


I ran the command 'mono-shlib-cop gdal_csharp.dll'. It produced the
following.

error: in OSGeo.GDAL.GdalPINVOKE.UseExceptions: Could not load library
`gdal_wrap': ./libgdal_wrap.so: cannot open shared object file: No such file
or directory
error: in OSGeo.GDAL.GdalPINVOKE.DontUseExceptions: Could not load library
`gdal_wrap': ./libgdal_wrap.so: cannot open shared object file: No such file
or directory
error: in OSGeo.GDAL.GdalPINVOKE.Debug: Could not load library `gdal_wrap':
./libgdal_wrap.so: cannot 



============================
CONCLUSIONS
============================
>From what I've read if the library is named properly (libgdal_wrap.so in
linux, gdal_wrap.dll in windows), and if the file exists in the path (PATH
in Windows, LD_LIBRARY_PATH in Linux) the native bindings should work.

If anyone has advice on gdal, on native-bindings, or on tracking down
type-loader-exceptions help is appreciated. Thanks...

 
-- 
View this message in context: http://www.nabble.com/gdal-mono-linux--Native-bindings%2C-PInvoke%2C-and-tracking-TypeLoader-exceptions-tp17622978p17622978.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list