|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
gdal/mono/linux; Native bindings, PInvoke, and tracking TypeLoader exceptionsFirst 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. 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... |
|
|
Re: gdal/mono/linux; Native bindings, PInvoke, and tracking TypeLoader exceptionsThis is a yes, me too response, but I've done some analysis on my own. First I was stuck on the DllNotFoundException. My next step was to call GDALAllRegister on gdal_fw (Gdal_wrap uses this one). (*All code was not cut and pasted*) [DllImport("gdal_fw")] public static extern void GDALAllRegister(); And created a small console app that runs this. When run from command line it runs just fine, but when run with mono it gave a DllNotFoundException (startled). The DLL could be found just fine, the environment path was the same, it pointed to the bin of gdal (I've used fwtools 2.2.8) ,.. so what could have gone wrong? I've PInvoked LoadLibrary from Kernel32 [DllImport("Kernel32"), SetLastError = true)] Public extern static int LoadLibrary(string name); When you run : Console.WriteLine(LoadLibrary("gdal_fw")); With normal .net it runs fine, a handle is returned. under mono it fails with error code (getlasterror) 182 meaning invalid ordinal? I've checked the dll dependencies of gdal_fw,.. and long story short, it seems the ssleay32.dll fails to load (182) when mono is run. The dependencies of ssleay32 load just fine. btw folks these are all unmanaged dll's.. Now it's time for me to give up. Hoping someone finds a solution, or an explanation why this would occur with mono running. regards Floris Briolas (used mono 2.0.1 on win xp) |
|
|
Re: gdal/mono/linux; Native bindings, PInvoke, and tracking TypeLoader exceptionshi
Sorry but i don't speek english... i was found the solution to the "ssleay32.dll" load problem. command line> del c:\your mono path\bin\libeay32.dll and if you run this code snippet: [DllImport("Kernel32", SetLastError = true)] public extern static int LoadLibrary(string name); static void Main() { ... Console.WriteLine("libeay32.dll:" + LoadLibrary("libeay32.dll").ToString ()); Console.WriteLine("ssleay32.dll: " + LoadLibrary("ssleay32.dll").ToString ()); ... } command line> mono test.exe libeay32.dll: 21037056 ssleay32.dll: 22347776 and it seems that works well! it seems a bug. regards |
| Free embeddable forum powered by Nabble | Forum Help |