Linux HOWTOs

About | Home | Search


HOWTO: openjpeg
Description: Open-source JPEG 2000 codec written in C
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# OpenJPEG 2.3.0
# ==============
# Slackware 14.2: openjpeg 2.1.0

# If you ever want to uninstall OpenJPEG or remove files from an old version
# before installing this one, skip down to the bottom

# Prerequisites:
# CMake
# zlib
# libpng
# libtiff
# lcms
# pkg-config
# doxygen (for 'make doc')

# 2.3.0 NEWS
# 2.3.0 ChangeLog

# Get it
cd
test -f installed/openjpeg-2.3.0.tar.gz &&
 mv installed/openjpeg-2.3.0.tar.gz .
test ! -f openjpeg-2.3.0.tar.gz &&
 wget https://github.com/uclouvain/openjpeg/archive/v2.3.0.tar.gz -O \
  openjpeg-2.3.0.tar.gz

# Extract it
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "OpenJPEG_*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "openjpeg-*" -exec rm -r {} \;
tar xzvf ~/openjpeg-2.3.0.tar.gz
cd openjpeg-2.3.0
test $UID = 0 && chown -R root:root .

# Build everything in a sub-directory
mkdir build
cd build

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
 cmake -DCMAKE_INSTALL_PREFIX=/usr -DOPENJPEG_INSTALL_LIB_DIR=/usr/lib64 ..

# Configure the build for anything else
test $(uname -m) != 'x86_64' && cmake ..

# Build it
make

# Become root to install it
su

# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg openjpeg

# Remove old library files
rm -f /usr/lib*/libopenjpeg.* /usr/local/lib*/libopenjpeg.*

# Install it
make install
ldconfig

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/openjpeg_*.tar.* installed/openjpeg-*.tar.*
mv openjpeg-2.3.0.tar.gz installed/


# If you ever want to uninstall OpenJPEG, this should do it:
su
cd ~/src/openjpeg-*/build
cat install_manifest.txt | xargs rm
for pfx in /usr /usr/local;
do
  cd $pfx
  ( cd bin
    rm -f image_to_j2k j2k_dump j2k_to_image obj_compress obj_decompress \
     obj_dump )
  find ./doc -type d -maxdepth 1 -name "openjpeg-*" -exec rm -r {} \;
  find ./include -type d -maxdepth 1 -name "openjpeg-*" \
   -exec rm -r {} \;
  for libdir in ${pfx}/lib ${pfx}/lib64;
  do
    find $libdir -maxdepth 1 -type d -name "openjpeg-*" -exec rm -r {} \;
    ( cd ${libdir}/pkgconfig
      rm -f libopenjp2.pc libopenjpeg1.pc )
  done
  ( cd man/man1 ; image_to_j2k.1 j2k_dump.1 j2k_to_image.1 )
  rm -f include/openjpeg.h man/man3/libopenjpeg.3
done
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "OpenJPEG_*" -exec rm -r {} \;
find ~/src -maxdepth 1 -type d -name "openjpeg-*" -exec rm -r {} \;
rm -f ~/installed/openjpeg_*.tar.* installed/openjpeg-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>