Installing Magick++

General

In order to compile Magick++ you must have access to a standard C++ implementation and have ImageMagick installed (ftp://ftp.wizards.dupont.com/pub/ImageMagick/). Magick++ is co-packaged as a subdirectory of ImageMagick as of ImageMagick version 4.2.2 and later. The author uses  gcc 2.95.2 (GNU C++) which is available under UNIX and under the Cygwin UNIX-emulation environment for Windows. Standards compliant commercial C++ compilers should also work fine. Most modern C++ compilers for PCs should also work (project files are provided in the VisualMagick package for Microsoft Visual C++ 6.0).

The compiler must support the following recent C++ standard features:

The author has personally verified that Magick++ compiles and runs using the following compiler/platform combinations:
 
Tested Configurations
Operating System
Architecture
Compiler
Solaris 2.6 SPARC egcs 1.1.2
Solaris 2.6 SPARC gcc-2.95.2
FreeBSD 2.2.7 Intel Pentium II egcs 1.1.2
Windows NT 4.0 SP6a Intel Pentium II Visual C++ 6.0 Standard Edition

User's of Magick++ have reported that the following configurations work with Magick++:
 
Other Working Configurations
Operating System
Architecture
Compiler
Reported By
Red Hat Linux 6.0 i386 egcs 1.1.2 Dr. Alexander Zimmermann <Alexander.Zimmermann@fmi.uni-passau.de>
Red Hat Linux 5.2 i386 egcs 1.1.2 (updated from SRPM) Dr. Alexander Zimmermann <Alexander.Zimmermann@fmi.uni-passau.de>
Red Hat Linux 5.2 Alpha egcs 1.1.2 (updated from SRPM) Dr. Alexander Zimmermann <Alexander.Zimmermann@fmi.uni-passau.de>
SGI IRIX MIPS IRIX C++ 7.2.1.2m Albert Chin-A-Young <china@thewrittenword.com>
SGI IRIX MIPS IRIX C++ 7.2.1.3m Albert Chin-A-Young <china@thewrittenword.com>
Mac OS 8.1? PowerPC CodeWarrior Professional Release 5 Leonard Rosenthol <leonardr@digapp.com>

Please let me know if you have successfully built and executed Magick++ using a different configuration so that I can add to the table of verified configurations.


Unix/Linux

Building From Source

To install the package under Unix, installation should be similar to

./configure [ --prefix=/prefix ]
make
make install

The configure script uses the compiler/linker flags it obtains from the installed 'Magick-config' script when performing the build. This means that ImageMagick must be installed before Magick++ is configured. The library is currently named similar to 'libMagick++.a' and is installed under prefix/lib while the headers are installed with Magick++.h being installed in prefix/include and the remaining headers in prefix/include/Magick++.

While it is currently possible to select building a shared Magick++ library (using the configure option --enable-shared), the resulting library may not be fully functional (exceptions and static constructors fail to work) because libtool does not yet arrange to invoke initializers when creating C++ shared libraries on most systems (reputed to work under Linux). A known workaround when using GNU C++ is to cd into the 'lib' subdirectory and execute an incantation similar to "c++ -shared -o .libs/libMagick++.so.0.0.0 *.lo -L/usr/local/lib -L/usr/openwin/lib -lMagick -ljbig -ldf -ltiff -lttf -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lX11 -lsocket -lnsl -lbz2 -lz -lm -lc". The exact incantation to use is derived from the one that libtool itself used. Obviously this is not for the faint of heart. If you plan to write many programs with Magick++, this effort may be worth it since it makes the executables *much* (typically 10X) smaller.

To influence the options the configure script chooses, you may specify environment variables when running the script. For example, the command
 

CXX=CC CXXFLAGS=-O2 LIBS=-lposix ./configure


specifies additional options to the configure script.  The following table shows the available options.
 
Environment Variables That Effect Configure
Environment Variable
Description
CXX
Name of C++ compiler (e.g. 'CC -Xa') to use compiler 'CC -Xa'
CXXFLAGS
Compiler flags (e.g. '-g -O2') to compile with
CPPFLAGS
Include paths (-I/somedir) to look for header files
LDFLAGS
Library paths (-L/somedir) to look for libraries. Systems that support the notion of a library run-path may additionally require -R/somedir or '-rpath /somedir' in order to find shared libraries at run time.
LIBS
Extra libraries (-lsomelib) required to link

Installing Linux RPMs

Dr. Alexander Zimmermann maintains Linux RPMs of ImageMagick and Magick++. These may be downloaded from ftp://ftp.forwiss.uni-passau.de/pub/linux/local/ImageMagick/. This site is  mirrored periodically to the ImageMagick linux directory and from there to the many ImageMagick and Linux mirror sites. Please note that the default version of the C++ compiler delivered with the system may not be sufficient to support Magick++. Use of Egcs 1.1.2 or gcc 2.95.2 is strongly recommended under Linux.

Windows '9X, and Windows NT

Visual C++

Windows NT is supported by an ImageMagick source package known as VisualMagick.  The VisualMagick source package provides sources to ImageMagick, Magick++, add-on libraries (e.g. JPEG), and a ready-made Visual C++ build environment. The easiest way to build Magick++ for Windows NT is to use the copy of Magick++ provided with VisualMagick. However, the copy of Magick++ provided with VisualMagick may be replaced with a newer Magick++ package if necessary.

Obtain and extract the VisualMagick source package, making sure to preserver subdirectories.

VisualMagick provides three ready-made build envionments:

VisualMagick (ImageMagick\VisualMagick\VisualMagick.dsw)
   Builds Debug and Release versions based on DLLs
VisualMagickStatic (ImageMagick\VisualMagick\VisualMagickStatic.dsw)
   Builds Debug and Release versions based on static libraries
VisualMagickX11 (ImageMagick\VisualMagick\VisualMagickX11.dsw)
   Builds Debug and Release versions based on DLLs, including X11 support
These build environments are based on similarly named workspaces in the VisualMagick subdirectory.

Open the desired workspace in Visual C++, select the menu named "Build", the menu entry "Batch Build", and then click on the "Rebuild All" button in order to build the complete VisualMagick package, including the Magick++ library.

Executables and DLLs are output to the directory ImageMagick\VisualMagick\bin. Linkable libraries are output to the directory ImageMagick\VisualMagick\lib.

The VisualMagick build does not build the Magick++ demos or tests. These are built by seperate workspaces.

Magick++ Demos
In order to build the Magick++ demos, open the workspace ImageMagick\VisualMagick\Magick++Demos.dsw and do a Batch Build, using the same options as used for VisualMagick. The executables for the demos are output to the ImageMagick\VisualMagick\bin directory. The demos may be executed by running the batch script Magick++Demo.bat in the directory ImageMagick\VisualMagick, with output files written to the directory ImageMagick\Magick++\demo. An alternative way to run the demos is to add the directory ImageMagick\VisualMagick\bin (with actual path prefix) to your path, and then cd to the ImageMagick\Magick++\demo directory before running the demo (e.g. 'button').

Available demos are:

button
   program to create a simple rectangular button with an annotation
flip
   program to invert and morph images in an existing GIF animation
demo
   program to demonstrate the image manipulation primitives
shapes
   program to demonstrate use of the drawing primitives
Magick++ Tests
In order to build the Magick++ tests, open the workspace ImageMagick\VisualMagick\Magick++Tests.dsw and do a Batch Build, using the same options as used  for VisualMagick.  The executables for the tests are output to the ImageMagick\VisualMagick\bin directory. The tests may be executed by running the batch script Magick++Tests.bat in the directory ImageMagick\VisualMagick, with output files written to the directory ImageMagick\Magick++\tests. An alternative way to run the tests is to add the directory ImageMagick\VisualMagick\bin (with actual path prefix) to your path, and then cd to the ImageMagick\Magick++\demo directory to run the test (e.g. 'appendImages').

The available tests are:

appendImages
   test STL appendImages function
attributes
   tests for setting/getting Magick::Image attributes
averageImages
   test STL averageImages function
coalesceImages
   test STL coalesceImages function
color
   test Magick::Color classes
montageImages
   test STL montageImages function
morphImages
   test STL morphImages function
readWriteBlob
   test reading/writing BLOBs
readWriteImages
   test STL readImages and writeImages functions

Cygwin & EGCS

It is possible to build both ImageMagick and Magick++ under the Cygwin Unix-emulation environment for Windows NT. Obtain and install Cgywin from http://sourceware.cygnus.com/cygwin/ and update to the latest GNU compiler from http://www.xraylith.wisc.edu/~khan/software/gnu-win32/gcc.html.   X11R6.4 libraries are available from http://dao.gsfc.nasa.gov/software/grads/win32/X11R6.4/.  To build using Cygwin and EGCS, follow the instructions for building under Unix. ImageMagick and Magick++ do not yet include support for building Windows DLLs under Cygwin so do not enable dynamic libraries when building ImageMagick.