Skip to content

Building KEA on Windows as a plugin

Sam Gillingham edited this page Mar 24, 2022 · 1 revision

[DRAFT]

On this page we will give some hints on how to build kealib on Windows so the GDAL plugin can be built.

Building KEA on Windows

Required:

You also need cmake and Visual Studio installed on your computer.

Note: these instructions build static versions of the dependencies of the GDAL plugin (zlib, hdf5 and kealib).

First call the vcvarsall.bat for the version of Visual Studio you are using so the compiler can be found.

Next, compile zlib (%VCINSTALLDIR% is the install location of the files). Extract the files and cding into that location and run these commands:

cmake -G "NMake Makefiles" ^
    -D CMAKE_BUILD_TYPE=Release ^
    -D CMAKE_INSTALL_PREFIX=%VCINSTALLDIR% ^
    -D BUILD_SHARED_LIBS=OFF ^
    .

nmake install

Then compile HDF5 by extracting the files and cding into that location and run these commands:

cmake -G "NMake Makefiles" ^
      -D CMAKE_BUILD_TYPE=Release ^
      -D CMAKE_INSTALL_PREFIX=%VCINSTALLDIR% ^
      -D CMAKE_PREFIX_PATH=%VCINSTALLDIR% ^
      -D HDF5_BUILD_CPP_LIB=ON ^
      -D HDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON ^
      -D ZLIB_ROOT=%VCINSTALLDIR% ^
      -D BUILD_SHARED_LIBS=OFF ^
      -D HDF5_BUILD_TOOLS=OFF ^
      -D HDF5_BUILD_EXAMPLES=OFF ^
      -D ZLIB_LIBRARY=%VCINSTALLDIR%\lib\zlibstatic.lib ^
      -D ZLIB_INCLUDE_DIR=%VCINSTALLDIR%\include ^
      -D ZLIB_USE_EXTERNAL=OFF ^
      -D BUILD_TESTING=OFF ^
      .

nmake install

Compile kealib by cding into the kealib sources and running these commands:

cmake -D HDF5_STATIC_LIBS=TRUE ^
      -D BUILD_SHARED_LIBS=OFF ^
      -D CMAKE_INSTALL_PREFIX=%VCINSTALLDIR% ^
      -D HDF5_INCLUDE_DIR=%VCINSTALLDIR%\include ^
      -D HDF5_LIB_PATH=%VCINSTALLDIR%\lib ^
      -D CMAKE_BUILD_TYPE=Release ^
      -G "NMake Makefiles" ^
      .

nmake install

Lastly, compile the GDAL plugin by going into the gdal subdirectory of the kealib sources and running these commands (note at this point you can recompile GDAL with kealib support to use the internal KEA driver instead - see https://gdal.org/drivers/raster/kea.html):

cmake -D KEAHDF5_STATIC_LIBS=TRUE ^
      -D CMAKE_INSTALL_PREFIX=%VCINSTALLDIR% ^
      -D LIBKEA_HEADERS_DIR=%VCINSTALLDIR%\include ^
      -D LIBKEA_LIB_PATH=%VCINSTALLDIR%\lib ^
      -D GDAL_INCLUDE_DIR=%VCINSTALLDIR%\include ^
      -D GDAL_LIB_PATH=%VCINSTALLDIR%\lib ^
      -D HDF5_INCLUDE_DIR=%VCINSTALLDIR%\include ^
      -D HDF5_LIB_PATH=%VCINSTALLDIR%\lib ^
      -D CMAKE_BUILD_TYPE=Release ^
      -G "NMake Makefiles" ^
      .

nmake install

Set the GDAL_DRIVER_PATH environment variable so GDAL can find the driver:

export GDAL_DRIVER_PATH=%VCINSTALLDIR%\lib\gdalplugin

Test the install

> gdalinfo --formats | grep KEA
  KEA (rw+): KEA Image Format (.kea)
Clone this wiki locally