Skip to content

Instantly share code, notes, and snippets.

@richardsawyer
Forked from marcinwol/dcmtk_compile.sh
Last active April 11, 2017 03:26
Show Gist options
  • Save richardsawyer/071cfe4b5cc1926a0c38e8805cdeb6eb to your computer and use it in GitHub Desktop.
Save richardsawyer/071cfe4b5cc1926a0c38e8805cdeb6eb to your computer and use it in GitHub Desktop.
Compile dcmtk 3.6.1 on Ubuntu 14.04 as static binaries
# The gist shows how to compile latest development snaphost of DCMTK 3.6.1
# in Ubuntu 14.04. The version of the dcmtk avaliable in ubuntu's repositiries
# is 3.6.0, which is from 2011. The gist also shows how to setup include
#and lib folders so thatwe can use them to write our own C++ programs
# using the develpment version.
# first need to install required packages
sudo apt-get install build-essential cmake libpng12-dev libtiff5-dev libxml2-dev libjpeg8-dev zlib1g-dev libwrap0-dev libssl-dev
# where to install DCMTK
export DCMTK_PREFIX=~/dcmtk361
# download latest development snapshot of the dcmtk. At the time of writing it was dcmtk-3.6.1_20150217.tar.gz
# for latest development versions please go to: http://dicom.offis.de/download/dcmtk/snapshot/
wget http://dicom.offis.de/download/dcmtk/snapshot/dcmtk-3.6.1_20170228.tar.gz
# unpack the archive
tar xzvf dcmtk-3.6.1_20170228.tar.gz
# go into the unpacked archive
cd dcmtk-3.6.1_20170228/
# run cmake to produce make file (alrenative to using ./configure --prefix=$DCMTK_PREFIX)
./configure LDFLAGS="-static"
# compile
make SHARED=0 CC='gcc -static' all
# install into prefix folder
make install
# files end up in /usr/local/bin
# as a result of the above commands the follwoing folders should be created in the $DCMTK_PREFIX
# bin, etc, include, lib, share
# optional to clean the dcmtk-3.6.1_20150217 from the files created
# during compilation.
# make clean
#----- READ BELOW when using ./configure --prefix=$DCMTK_PREFIX instead of cmake ----#
# when ./configure --prefix=$DCMTK_PREFIX is used to configure the dmckt for
# compilation and installation, the execution of the "make install" for
# this development snapshot version wont produce $DCMTK_PREFIX/lib and $DCMTK_PREFIX/include
# directories with header and library files required when wanting to write C++11 that uses
# this snapshot version. Thus, we need to create them ourselfs.
if false; then
# Copy dmcktk library files that were compilied into our $DCMTK_PREFIX/lib folder
mkdir $DCMTK_PREFIX/lib
find . -name "*.a" -exec sh -c 'echo "Copying ${0}"; cp -Rp "${0}" $DCMTK_PREFIX/lib' {} \;
# Now do the same but for header files.
mkdir $DCMTK_PREFIX/include
find . -type d -name "dcmtk" -exec sh -c 'echo "Copying ${0}"; cp -Rp "${0}" $DCMTK_PREFIX/include/' {} \;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment