MaxRev-Dev / gdal.netcore

GDAL 3.x C#/F# bindings for .NET apps
MIT License
161 stars 36 forks source link

[BUG] Fedora 35 / .NET 6 - Exception when executing GdalBase.ConfigureAll() #68

Closed abspro closed 2 years ago

abspro commented 2 years ago

Describe the bug On Fedora 35 when targeting a .NET 6 project an exception is thrown when GdalBase.ConfigureAll() is executed. I was following the steps in this article to read a FileGDB using the OpenFileGDB gdal driver.

https://www.spatial-focus.net/blog/working-with-file-geodatabase-in-csharp-1

To Reproduce

mkdir test cd test dotnet new console dotnet add package MaxRev.Gdal.Core dotnet add package MaxRev.Gdal.LinuxRuntime.Minimal edit Program.cs:


using MaxRev.Gdal.Core;

try { GdalBase.ConfigureAll(); } catch(Exception ex) { Console.WriteLine(ex); }

> dotnet build
> dotnet run

**Expected behavior**
I expected initialization to not throw an exception.

**Screenshots**

System.TypeInitializationException: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'gdal_wrap' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgdal_wrap: cannot open shared object file: No such file or directory at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Gdal(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate) at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..cctor() --- End of inner exception stack trace --- at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..ctor() at OSGeo.GDAL.GdalPINVOKE..cctor() --- End of inner exception stack trace --- at OSGeo.GDAL.GdalPINVOKE.AllRegister() at OSGeo.GDAL.Gdal.AllRegister() at MaxRev.Gdal.Core.GdalBase.ConfigureGdalDrivers() at MaxRev.Gdal.Core.GdalBase.ConfigureAll() at Program.

$(String[] args) in /home/blahblahblah/src/test/Program.cs:line 6



**Environment information:**
 - OS (version): Fedora Linux 35
 - Package version (core): 3.3.3.110
 - Package version (runtime): 3.3.3.110
MaxRev-Dev commented 2 years ago

Sooner or later it had to happen. Debugging via LD_DEBUG revealed some missing symbols on Fedora's distro. undefined symbol: _dl_make_stack_executable, version GLIBC_PRIVATE (./libpthread.so.0) That happened because the runtime tried to load native dependencies from another distro (CentOS 7) which I included by default. In the next hotfix, libm, libc and other system libraries will be removed from the Linux package.