Skip to main content

Building LightZone from Git for Linux

Intro

Hello! Since I read on LWN.net that the LightZone source code has been released as free software, I was curious to see if that software was compile- and runnable on my very machine. A friend of mine actually uses digital darkroom software and was still looking for something that worked on Linux. So I was curious if it could be done. When googling for "build LightZone Linux" or "compile LightZone Linux" there does not seem to be much help so I'm writing about a recipe that worked for me here. From now on I refer to a Git snapshot of 2013-01-06, commit ed3d11e5a1a3774d0b242722a4ee8315d7fe634d precisely. My understanding of LightZone is still in the process of building up so if you have any corrections or extensions to this, please comment below. Thanks!

Quick code and build system overview

LightZone is written in Java and C/C++, the build system uses Ant and GNU make, more precisely Ant calling GNU make. The code base is split to four major components/folders:

  • lightcrafts
  • linux
  • macosx
  • windows

The Java code strictly requires Sun Java 6 at the moment, since internal classes (e.g. from package com.sun.image) are used. When compiling you get warnings like

warning: com.sun.image.codec.jpeg.JPEGCodec is Sun proprietary API and may be removed in a future release

and with Java 7 these classes were actually removed. Also, since Java is involved, there are a bunch of pre-compiled .jar files (and one .so file) in the Git repository. Ideally, you replace these with self-built versions, e.g. for security reasons. Comparing the set of .class files from the .jar archives with the sets of .java files of available Subversion tags leads to this mapping for unbundling:

  • linux/lib/libmlib_jai.so — sun-jai-bin 1.1.3
  • linux/lib/jh.jar — javahelp 2.0.05
  • linux/lib/mlibwrapper_jai.jar — sun-jai-bin 1.1.3
  • lightcrafts/lib/script-api.jar — replace with empty .jar file, code included in Sun Java 6
  • lightcrafts/lib/substance-lite.jar — substance 3.3 (with integrated laf-widget 3.0 and laf-plugin 1.0)

Several C/C++ libraries are bundled too. I have not bothered unbundling those, yet.

Fixing

A few things are broken, other things just could use some tuning. Patches for all of these issues can be found in Gentoo betagarden. Broken things include:

  • The build system hard-codes our machine to be Pentium 4.
  • One of the makefiles does not support GNU make 3.82 or later.
  • uname -p is called where uname -m seems needed.
  • The C++ code misses symbol CHAR_BIT and uses unavailable _mm_srai_epi64.
  • The fork daemon location (LightZone-forkd) needs some adjustment.
  • build.xml references a .jar file from the windows folder even for Linux builds.
  • Some files raise UTF-8 errors from Java since they are encoded as Latin1.

Other things you might want to patch:

  • Crash reports should be off by default.
  • The license check should be skipped.
  • Unpatched, LightZone calls itself version "3.9.1 (-1)" with -1 being a Subversion revision.

Building

Once you have patched the issues mentioned earlier, building is as easy as:

$ ( cd lightcrafts && ant )
$ ( cd linux && ant )

Installation

If you are aiming at a package for a Linux distribution, the installed files and locations could be something like this:

/usr/bin/LightZone              # Bash script invoking Java VM, details later
/usr/bin/LightZone-forkd        # Fork daemon ELF binary called by Java code
/usr/lib64/LightZone/*.so       # ELF libraries
/usr/share/LightZone/lib/*.jar  # Java code

In a non-packaging scenario, /usr/local or /opt may make better destinations. These are the .jar files you need to install:

  • lcjai.jar
  • lightcrafts-linux.jar
  • lightcrafts.jar
  • lightzonehelp.jar

Some of those you find twice: one symlink and one regular file. The regular file is what you want, just ignore the symlink. File script-api.jar does not really seem needed, since Sun Java 6 includes that code already. If you manage to unbundle Substance, substance-lite.jar is no longer needed either.

Execution

From an execution script you expect the following:

  • Start a Java VM and make it run the Linux launcher as the main class
  • Add all needed .jar files to the class path
  • Ensure that the .so files are found, i.e, setting java.library.path and LD_LIBRARY_PATH

The script could be something like this:

#! /usr/bin/env bash
jar_dir=/usr/share/LightZone/lib
so_dir=/usr/lib64/LightZone

export LD_LIBRARY_PATH="${so_dir}"

exec java -classpath "${jar_dir}"/lightcrafts-linux.jar\
:"${jar_dir}"/lightzonehelp.jar\
:"${jar_dir}"/lcjai.jar\
:"${jar_dir}"/lightcrafts.jar\
:/usr/share/substance/lib/substance-lite.jar\
:/usr/share/javahelp/lib/jh.jar\
:/usr/share/sun-jai-bin/lib/mlibwrapper_jai.jar \
-Djava.library.path=/usr/lib64/sun-jai-bin:/lib:/usr/lib:"${so_dir}" \
com.lightcrafts.platform.linux.LinuxLauncher

That's it for a start. Please contact me, if you have any quesions.