This project is read-only.

GDAL - Which GdalExtension to use?

Feb 3, 2011 at 6:16 PM

In the DotSpatial.sln there are three Gdal Extension projects:

  1. DotSpatial.Data.Rasters.Gdal1-7Extension32
  2. DotSpatial.Data.Rasters.Gdal1-7Extension64
  3. DotSpatial.Data.Rasters.GdalExtension

1) If I want to support GDAL rasters in my application, which of these GdalExtensions should I distribute with my application?

2) Currently my c# application is built as 'Any CPU' with 4.0 target framework. To make GDAL work with my application on any Windows system, Do I need to change this setup and distribute two separate builds of my application (64bit and 32bit) ?

Any advice is highly appreciated.

Feb 3, 2011 at 7:57 PM

So here is your scenario.  In order to use GDAL, you must abandon any hope of having a single build "Any CPU" that can run equally on both 32 and 64 frameworks.  It is unmanaged code and must be compiled for one or the other, which basically means that in order to reference it, your project must match it all the way up.  Therefore, if you are building on a 64 machine as AnyCPU, and all clients you expect to target have a 64 machine, then you can build with 2 (7Extension64).  If you are on a 32 machine, you must build with 1 (7Extension32) since your computer cannot understand the binary in 2 at all.  If you are on a 64 machine, but your clients are probably on a 32 machine, then you must target the x86 framework in your project settings.  Failure to change it from "AnyCPU" will result in you building to the x64 framework.  Once you have targeted x86, then you must also use a variant of DotSpatial that is targeted for x86.  DotSpatial is already set up with this build configuration, so it's just a matter of making sure the GDAL 7-32 extension is checked, which should already be done for you in that solution configuration.   As long as you are building for 4.0, you don't need to ever build or deploy 3.  The only reason we keep 3 is because 1 and 2 will not work without the 4.0 framework and because 3 contains the actual source code that 1 and 2 link to.  In other words, if you need to fix something in 1 or 2, you actually need to edit 3, and this will fix the problem in all 3 versions.

So for re-deployment, the short answer is, build dotspatial with the correct configuration, then use whatever files show up in the Data Extensions\GDAL folder.  They should be the correct files for that configuration of DotSpatial.





Feb 3, 2011 at 10:40 PM

Thanks for the detailed explanation Ted,

This helps.

Feb 4, 2011 at 5:17 PM

Here is a quick way how to make GDAL rasters open in DotSpatial DemoMap on a 32-bit computer:

  1. Open DotSpatial.sln
  2. In the main menu go to Build - Configuration Manager
  3. Change 'Active solution platform' to 'x86'
  4. Build solution