HDF4 support for GDAL on Arch Linux

I have been trouble reading HDF files with OTB on Arch Linux for a while. I finally took the time to investigate this problem and come to a solution.

At the beginning I was misled by the fact that I was able to open a HDF5 file with Monteverdi on Arch. But I finally understood that the GDAL pre-compiled package for Arch was only missing HDF4 support.
It is due to the fact that HDF4 depends on libjpeg version 6, and is incompatible with the standard current version of libjpeg on Arch.
So the solution is to install libjpeg6 and HDF4 from the AUR and then regenerate the gdal package, who, during the configuration phase will automatically add HDF4 support.
Here are the detailed steps I took:

  1. Install libjpeg6 from AUR:
    1. mkdir ~/local/packages
    2. cd ~/local/packages
    3. wget http://aur.archlinux.org/packages/libjpeg6/libjpeg6.tar.gz
    4. tar xzf libjpeg6.tar.gz
    5. cd libjpeg6
    6. makepkg -i #will prompt for root psswd for installation
  2. Install HDF4 from AUR:
    1. cd ~/local/packages
    2. wget http://aur.archlinux.org/packages/hdf4-nonetcdf/hdf4-nonetcdf.tar.gz
    3. tar xzf hdf4-nonetcdf.tar.gz
    4. cd hdf4-nonetcdf
    5. makepkg -i #will prompt for root psswd for installation
  3. Setup an Arch Build System build tree
    1. sudo pacman -S abs
    2. sudo abs
    3. mkdir ~/local/abs
  4. Compile gdal
    1. cp -r /var/abs/community/gdal ~/local/abs
    2. makepkg -s #generated the package without installing it
    3. sudo pacman -U gdal-1.8.0-2-x8664.pkg.tar.gz

If you are new to using AUR and makepkg, please note that the AUR package installation need the sudo package to be installed first (the packages are build as a non root user and sudo is called by makepkg).
Step 3 above is only needed if you have never set up the Arch Build System on your system.

8 thoughts on “HDF4 support for GDAL on Arch Linux”

  1. Hi Jordi,
    We’ve tried your procedure in order to get gdal working with hdf4 files on a new ArchLinux computer. Unfortunately, it doesn’t work for us (when we call gdlinfo with an hdf4 file, it says that the format is not supported). We use a i686 platform and I don’t know if it the reason of the failure. May be you have any idea for helping us. Thanks a lot.
    Tovo R.

  2. Just a quick update: gdal builds by default with the external libtiff in arch which does not support bigtiff. In order to get support for bigtiff one has to modify the PKGBUILD file and set “–with-libtiff=internal” in the configure options.

  3. Thanks Jordi for your reply (and happy new year !!)
    Our problem is that by following your tutorial, we ain’t have any hdf4 support.
    While doing the part 4, somewhere, we have :
    HDF4 support: no
    HDF5 support: yes
    And obviously, after compiling, hdf4 is not supported by gdal.
    We tried to modify the GDAL PKGBUILD by changing hdf5 with hdf4 but, we have the following error :
    configure: error: HDF4 support requested with arg “yes”, but neither hdf4 nor mfhdf lib found.
    Thanks for your help
    Cheers

    1. Was step 2 above successful? If you use “yaourt” (the package manager with AUR support), you can check if HDF4 is installed with:

      sudo yaourt -Ss hdf4 | grep installed

      Try this and tell me what you find.

      Good luck!

      Jordi

  4. Well, I don’t have any other idea than telling the gdal configure where your hdf4 lib is. I can’t check it now, but I guess that it may be possible to give the path to the –with-hdf4 flag.

    Is your hdf4 lib installed in a non standard directory?

  5. Thanks Jordi,
    After many retries, we succeeded. Finally, we decided to follow the tutorial till the step 3, and to compile GDAL independently from Arch packages management. We also added the –with-gdal4 flag for the compiling. The next big problem was to install Qgis and Grass … but it’s another story 😉

Leave a Reply