Skip to content

eraigosa/gdal.netcore

 
 

Repository files navigation

gdal.netcore

A simple (as is) build engine of GDAL 3.0 library for .NET Core.

Packages

NuGet: MaxRev.Gdal.Core

NuGet: MaxRev.Gdal.LinuxRuntime.Minimal

NuGet: MaxRev.Gdal.WindowsRuntime.Minimal

Table Of Contents

About this library

What is this library

  • Only generates assemblies and binds everything into one package.
  • Provides easy access to GDAL by installing only core and runtime package
  • DOES NOT require installation of GDAL

What is not

  • Does not compile all drivers. Only configured, they are listed below. By default GDAL has a lot of internal drivers.
  • Does not change GDAL source code.
  • Does not extend GDAL methods.

How to compile on Windows

It's quite tricky. Enter win directory to find out how.

How to compile on Unix

Current version targets GDAL 3.0.1 with minimal drivers

Drivers included PROJ6, SQLITE3, GEOS(3.8), HDF4, HDF5, GEOTIFF, JPEG, PNG, LIBZ, LERC, CURL

Configure summary of current version
  GDAL is now configured for x86_64-pc-linux-gnu
  Installation directory:    /mnt/e/dev/builds/gdal-netcore/build-unix/gdal-build
  C compiler:                gcc -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -fPIC -fvisibility=hidden
  C++ compiler:              g++ -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2 -fvisibility=hidden
  C++14 support:             no

  LIBTOOL support:           yes
  
  LIBZ support:              internal
  LIBLZMA support:           no
  ZSTD support:              no
  cryptopp support:          no
  crypto/openssl support:    no
  GRASS support:             no
  CFITSIO support:           no
  PCRaster support:          no
  LIBPNG support:            internal
  DDS support:               no
  GTA support:               no
  LIBTIFF support:           internal (BigTIFF=yes)
  LIBGEOTIFF support:        internal
  LIBJPEG support:           internal
  12 bit JPEG:               yes
  12 bit JPEG-in-TIFF:       yes
  LIBGIF support:            no
  JPEG-Lossless/CharLS:      no
  OGDI support:              no
  HDF4 support:              yes
  HDF5 support:              yes
  Kea support:               no
  NetCDF support:            no
  Kakadu support:            no
  JasPer support:            no
  OpenJPEG support:          no
  ECW support:               no
  MrSID support:             no
  MrSID/MG4 Lidar support:   no
  JP2Lura support:           no
  MSG support:               no
  EPSILON support:           no
  WebP support:              no
  cURL support (wms/wcs/...):yes
  PostgreSQL support:        no
  LERC support:              yes
  MySQL support:             no
  Ingres support:            no
  Xerces-C support:          no
  Expat support:             no
  libxml2 support:           no
  Google libkml support:     no
  ODBC support:              no
  FGDB support:              no
  MDB support:               no
  PCIDSK support:            no
  OCI support:               no
  GEORASTER support:         no
  SDE support:               no
  Rasdaman support:          no
  DODS support:              no
  SQLite support:            yes
  PCRE support:              no
  SpatiaLite support:        no
  RasterLite2 support:       no
  Teigha (DWG and DGNv8):    no
  INFORMIX DataBlade support:no
  GEOS support:              yes
  SFCGAL support:            no
  QHull support:             no
  Poppler support:           no
  Podofo support:            no
  PDFium support:            no
  OpenCL support:            no
  Armadillo support:         no
  FreeXL support:            no
  SOSI support:              no
  MongoDB support:           no
  MongoCXX v3 support:       no
  HDFS support:              no
  TileDB support:            no
  userfaultfd support:       yes
  misc. gdal formats:        aaigrid adrg aigrid airsar arg blx bmp bsb cals ceos ceos2 coasp cosar ctg dimap dted e00grid elas envisat ers fit gff gsg gxf hf2 idrisi ignfheightasciigrid ilwis ingr iris iso8211 jaxapalsar jdem kmlsuperoverlay l1b leveller map mrf msgn ngsgeoid nitf northwood pds prf r raw rmf rs2 safe saga sdts sentinel2 sgi sigdem srtmhgt terragen til tsx usgsdem xpm xyz zmap rik ozi grib eeda plmosaic rda wcs wms wmts daas rasterlite mbtiles pdf
  disabled gdal formats:
  misc. ogr formats:         aeronavfaa arcgen avc bna cad csv dgn dxf edigeo geoconcept georss gml gmt gpsbabel gpx gtm htf jml mvt ntf openair openfilegdb pgdump rec s57 segukooa segy selafin shape sua svg sxf tiger vdv wasp xplane idrisi pds sdts amigocloud carto cloudant couchdb csw elastic gft ngw plscenes wfs gpkg vfk osm
  disabled ogr formats:
  
  SWIG Bindings:             no
  
  PROJ >= 6:                 yes
  enable GNM building:       no
  enable pthread support:    yes
  enable POSIX iconv support:yes
  hide internal symbols:     yes

NOTE: Windows and Linux drivers availability may differ, ask me of specific driver for runtime. Please issue, if I forgot to mention any other packages.

Prerequisites

First of all I wish you to be patient & bring your snacks. Compilation from scratch takes nearly for 2 hours.

Environment: I'm compiling in WSL on CentOS 7 with GLIBC 2.17 (2012)

  1. yum install tcl tcl-devel -y - for building sqlite3
  2. yum install patchelf -y - dynamic linking

If you have installed libsqlite3-dev and proj6 - go forward to step #3

If you have libsqlite3-dev installed you may skip the first step.

Set a root variable for convenience export gc_root=`pwd`

Soo.. Let's start

Easy way compiling

Assuming you have tclsh for compiling sqlite3

make -f GdalMakefile

this will compile sqlite3, proj6, geos and gdal from scratch

Alternate way

1. Compile SQLite3 (optional)

  1. Download SQLite3 Autoconf & unpack (GdalMakefile uses git for this)

    mkdir $gc_root/build-unix  
    curl -o sqlite.tar.gz "https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz"
    tar xfv sqlite.tar.gz && mv sqlite-autoconf-3290000 sqlite3-source && cd sqlite3-source
  2. Configure sqlite3

    ./configure --prefix=$gc_root/sqlite3-build
  3. Compile and install

    make && make install && cd $gc_root

2. Compile PROJ6

  1. Download proj & unpack (GdalMakefile uses git for this)

    mkdir $gc_root/build-unix
    curl -o proj-6.1.0.tar.gz "https://download.osgeo.org/proj/proj-6.1.0.tar.gz"
    tar xfv proj-6.1.0.tar.gz && mv proj-6.1.0 proj6-source && cd proj6-source
  2.  ./configure CFLAGS="-fPIC" --prefix=$gc_root/proj6-build
  3.  make LDFLAGS="-Wl,-rpath '-Wl,\$\$ORIGIN' -L$gc_root/sqlite3-build/lib" && make install && cd $gc_root  

Note: you must specify the sqlite3 library custom location with -L flag

3. Clone and Compile GDAL

You can build gdal using GdalMakefile, but before you must setup paths in GdalCore.opt file. Also you must change configuregdal.sh script to setup necessary drivers.

Then you may just call make -f GdalMakefile gdal - this will sync gdal repository, configure it and finaly build.

Or alternatively... (assuming you are in the root of this repo)

  1. git clone https://github.com/OSGeo/gdal.git $gc_root/build-unix/gdal-source
  2. cd $gc_root && make -f GdalMakefile configure_gdal #calls ./configuregdal.sh
  3. make -f GdalMakefile build_gdal

After you have gdal installed, you can proceed to netcore bindings build.

4. Build a wrapper

  1. Edit library path for proj & gdal (configured above) in GNUMakefile

  2. cd $gc_root && make interface
  3. make RID=linux-x64 #NOTE: You must call it TWICE. Thas a bug in linker
  4. Cheers!

Building Nuget Packages

Prerequisites

  1. Install .NET Core SDK and Nuget.exe - for building and publishing packages
  2. You have already built everything

Packaging

  1. I'm using debian for example:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get install apt-transport-https && apt-get update && apt-get install dotnet-sdk-2.2
  1. And then just
make pack

FAQ

Q: Missing {some} drivers, can you add more?

A: Feel free to contribute and I will help you you to add them. Here's the my additional answer.

Q: GDAL functions are not working as expected

A: Try to search an issue on github. In 98% cases, I'm sure they are working fine.

Q: Some types throw exceptions from SWIG on Windows

A: Yes, currently there are some redundant types in OGR namespace. This will be fixed in the next builds.

Q: Can't compile on Windows

A: I've built it on my machine several times from scratch. Do you have installed all SDKs? If you know cmake or nmake you can help to port batch files that are buggy.

Q: Can I compile it on Ubuntu or another Unix-based system?

A: The main reason I'm compiling it on CentOS - glibc of version 2.17. It's the lowest version (in my opinion) that suits for all common systems (Ubuntu, Debian, Fedora)

Q: In some methods performance is slower on Unix

A: Use of older version of GLIBC might be a reason. But It's not a fault of build engine.

About and Contacts

based on https://github.com/OSGeo/gdal && https://github.com/jgoday/gdal

Contact me: Telegram - MaxRev

Enjoy!

About

GDAL 3.0 bindings for .Net Core apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • SWIG 94.3%
  • C 1.2%
  • Batchfile 1.1%
  • Makefile 1.0%
  • OCaml 0.9%
  • Scheme 0.7%
  • Other 0.8%