wiki:JP2KAK

JP2KAK

JP2KAK is the Kakadu based GDAL Driver for JPEG2000 image data. There are several other JPEG2000 drivers as well (JPEG200 - JasPer, JP2MRSID - MrSID SDK, JP2ECW - ECW SDK). The Kakadu library is proprietary, but can be licensed under reasonable terms for various uses. Unfortunately it comes with a slightly unusual build system which makes it hard to build against.

Most of the follow describes use of Kakadu 6.x versions. Kakadu V7.2.2 may be built with GDAL "trunk" as April 2013 but the changes (r25950) did not make it into GDAL 1.10.0.

Building Kakadu on Unix/Linux

The following guide walks through steps required to build Kakadu 6.0 and GDAL with JP2KAK driver support on 64-bit Linux machine. Instructions presented here have been tested under Ubuntu Linux.

  • Prerequisites

You have obtained Kakadu source code and license in version 6.0.

  • Unpack Kakadu 6.0 sources to preferred location
$ cp v6_0-00256n.zip /usr/local
$ cd /usr/local
$ unzip v6_0-00256n.zip
$ mv v6_0-00256N kakadu-6.0

Note: I assume you have sufficient privileges to operate in /usr/local directory or you have chosen different location.

The location /usr/local/kakadu-6.0 will be used as building workspace and also as installation directory, because there is no make install step when building Kakadu.

$ cd /usr/local/kakadu-6.0

Check if you have following directories and files in there:

$ ls
apps  bin  Compiling_Instructions.txt  contrib  coresys  documentation  language  lib  LICENSE.TXT  mail_to  make  managed  Updates.txt
  • Build subtree coresys
$ cd coresys/make
$ make -f Makefile-Linux-x86-64-gcc 
$ cd ../..
  • Build subtree apps:
    cd apps/make
    $ vi Makefile-Linux-x86-64-gcc  (add C_OPT += -fPIC)
    $ make -f Makefile-Linux-x86-64-gcc 
    $ cd ../..
    
  • Copy libraries to location where GDAL expects to find them
$ pwd
/usr/local/kakadu-6.0
$ mv lib/Linux-x86-64-gcc/* lib/

After this step, Kakadu libraries can be found here:

$ cd /usr/local/kakadu-6.0/lib
$ ls lib*
libkdu.a  libkdu_v60R.so

Building GDAL with Kakadu support

  • Configuration
$ ./configure --with-kakadu=/usr/local/kakadu-6.0

As you see, --with-kakadu option takes root (prefix) of Kakadu installation directory. As mentioned in the previous section, GDAL building scripts will look for Kakadu binaries in subdirectory /usr/local/kakadu-6.0/lib.

Verify if ./configure successfully detected Kakadu files:

...
GDAL is now configured for i686-pc-linux-gnu

  Installation directory:    /home/mloskot/usr
  C compiler:                gcc -O2 
  C++ compiler:              g++ -O2 

  LIBTOOL support:           no

...
  KAKADU support:            yes
...
  • Build GDAL with JP2KAK driver
$ make
$ make install
  • Verify if JP2KAK is included
$ gdalinfo --formats | grep JP2KAK
  JP2KAK (rw): JPEG-2000 (based on Kakadu)

Yeah! You can also list detailed information of JP2KAK driver passing --format option:

$ gdalinfo --format JP2KAK
Format Details:
  Short Name: JP2KAK
  Long Name: JPEG-2000 (based on Kakadu)
  Extension: jp2
  Mime Type: image/jp2
  Help Topic: frmt_jpeg2000.html
  Supports: CreateCopy() - Create dataset by copying another.
  Creation Datatypes: Byte Int16 UInt16
...

Windows Builds

Kakadu (6.2.1 at least) comes with solution files for VS2005 and VS2008. I used Visual Studio Express 2008 successfully to build the solution in the coresys and apps directories but I first had to modify the coresys.rc file to avoid a dependency on afxres.h. I did this, similar to the gdal .rc file:

// Generated from the TEXTINCLUDE 2 resource.
//
//#include "afxres.h"

#define APSTUDIO_HIDDEN_SYMBOLS
#include <windows.h>
#undef APSTUDIO_HIDDEN_SYMBOLS
#include <winver.h>

In GDAL/OGR trunk (1.7dev) I have substantially updated the makefile.vc and nmake.opt entries for Kakadu support. Now it should be sufficient to update the nmake.opt entries appropriately for your local tree:

# Uncommment if you have Kakadu 6.0 or newer
KAKDIR = 	\warmerda\pkg\kakadu-6.2.1
KAKLIB =	$(KAKDIR)\lib_x86\kdu_v62R.lib
KAKSRC =	$(KAKDIR)\v6_2_1-00256N

This assumes that the source was unpacked inside $(KAKDIR) and that the normal solutions were used to build stuff - they put the resulting object code, dlls and executables a directory above the source tree. Under some circumstances it may be necessary to change some definitions in gdal/frmts/jp2kak/makefile.vc such as:

OBJ_PREFIX =	$(KAKDIR)\v6_generated_x86
OBJ_CONFIG =	release

or

EXTRAFLAGS = 	$(KAKINC) /DKDU_PENTIUM_MSVC /EHsc

Do not forget to copy the DLL from the $(KAKDIR)\bin_x86 directory or to add it to the path.

Note that GDAL/OGR 1.6.x and earlier use another makefile structure based on the assumption that the Kakadu stuff is being built in a idiosyncratic manner. It may be best to copy the trunk makefile.vc into gdal/frmts/jp2kak and add the above definitions normally found in nmake.opt in it directly.

Open Tickets

No results

Last modified 11 years ago Last modified on Apr 29, 2013, 5:20:16 PM
Note: See TracWiki for help on using the wiki.