wiki:JP2KAK

Version 13 (modified by warmerdam, 15 years ago) ( diff )

added jp2kak build notes on win32.

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.

Building Kakadu on Unix/Linux

The following guide walks through steps required to build Kakadu 6.0 and GDAL with JP2KAK driver support on 32-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-32-gcc 
$ cd ../..
  • Build subtree apps
cd apps/make
$ make -f Makefile-Linux-x86-32-gcc 
$ cd ../..
  • Copy libraries to location where GDAL expects to find them
$ pwd
/usr/local/kakadu-6.0
$ mv lib/Linux-x86-32-gcc/* lib/

After this step, Kakadu libraries can be found here:

$ cd /usr/local/kakadu-6.0/lib
$ ls lib*
libkdu.a  libkdu_stacksafe32.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
...

Unix/Linux Builds by Frank

This is how I setup to use Kakadu 6.0 on my 64bit linux system with GDAL 1.4.x. Other makefiles exist for 32bit linux and a few other variations. You may have to fiddle with the makefiles some if your environment is odd.

(this is in progress - my build with v6 isn't actually working yet)

unzip v6_0-00256n.zip 
mv v6_0-00256N kakadu-6.0
cd kakadu-6.0/coresys/make
make -f Makefile-Linux-x86-64-gcc
cd ../../
cp lib/Linux-x86-64-gcc/* /usr/local/lib
cd apps/make

Edit to add -fPIC in compile options.

make -f Makefile-Linux-x86-64-gcc

Then I configure GDAL like this:

./configure --with-kakadu=/home/warmerda/pkg/kakadu-6.0

and build. The Kakadu libraries are used as static libraries, so there are no .so's to carry along.

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

Note: See TracWiki for help on using the wiki.