blob: 8b53db291c9ee54ea34c8cc1cdd070d389591a79 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001UNIX/Cygwin/MinGW COMPILATION
2
3Note:
4
5 Platform specific notes regarding specific operating systems may be found
6 in the Platforms.txt file. This document provides generic instructions
7 which work in most common cases. Additional notes regarding Cygwin &
8 MinGW are provided later in this file.
9
10Type:
11
12 gzip -dc ImageMagick-6.5.4.tar.gz | tar xvf -
13 cd ImageMagick-6.5.4
14
15If you do not have gzip(1), the source for the gzip package is available
16as a shell archive at
17
18 ftp://ftp.gnu.org/gnu/gzip/gzip-1.2.4a.shar
19
20or as a tar archive at
21
22 ftp://ftp.gnu.org/gnu/gzip/gzip-1.2.4a.tar
23
24Use the 'configure' script to automatically configure, build, and install
25ImageMagick. The configure script may be executed from the ImageMagick source
26directory (e.g ./configure) or from a seperate build directory by specifying
27the full path to configure (e.g. /src/ImageMagick-6.5.4/configure). The
28advantage of using a seperate build directory is that multiple ImageMagick
29builds may share the same ImageMagick source directory while allowing each
30build to use a unique set of options.
31
32If you are willing to accept configure's default options, and build from
33within the source directory, type:
34
35 ./configure
36
37and watch the configure script output to verify that it finds everything
38that you think it should. If it does not, then adjust your environment
39so that it does.
40
41By default,
42
43 make install
44
45will install the package's files in `/usr/local/bin', `/usr/local/lib', etc..
46You can specify an installation prefix other than `/usr/local' by giving
47`configure' the option `--prefix=PATH'. This is valuable in case you don't
48have privileges to install under the default paths or if you want to install
49in the system directories instead.
50
51If you are not happy with configure's choice of compiler, compilation flags,
52or libraries, you can give `configure' initial values for variables by
53specifying them on the configure command line, e.g.:
54
55 ./configure CC=c99 CFLAGS=-O2 LIBS=-lposix
56
57Options which should be common to packages installed under the same directory
58heirarchy may be supplied via a 'config.site' file located under the
59installation prefix via the path ${prefix}/share/config.site where ${prefix} is
60the installation prefix. This file is used for all packages installed under
61that prefix. This is an example config.site file:
62
63 # Configuration values for all packages installed under this prefix
64 CC=gcc
65 CXX=c++
66 CPPFLAGS='-I/usr/local/include'
67 LDFLAGS='-L/usr/local/lib -R/usr/local/lib'
68
69When the 'config.site' file is being used to supply configuration options,
70configure will issue a message similar to:
71
72 configure: loading site script /usr/local/share/config.site
73
74The configure variables you should be aware of are:
75
76 CC Name of C compiler (e.g. 'cc -Xa') to use
77 CXX Name of C++ compiler to use (e.g. 'CC')
78 CFLAGS Compiler flags (e.g. '-g -O2') to compile C code
79 CXXFLAGS Compiler flags (e.g. '-g -O2') to compile C++ code
80 CPPFLAGS Include paths (-I/somedir) to look for header files
81 LDFLAGS Library paths (-L/somedir) to look for libraries
82 Systems that support the notion of a library run-path
83 may require an additional argument in order to find
84 shared libraries at run time. For example, the Solaris
85 linker requires an argument of the form '-R/somedir',
86 some Linux systems will work with '-rpath /somedir',
87 while some other Linux systems who's gcc does not pass
88 -rpath to the linker require an argument of the form
89 '-Wl,-rpath,/somedir'.
90 LIBS Extra libraries (-lsomelib) required to link
91
92Any variable (e.g. CPPFLAGS or LDFLAGS) which requires a directory path must
93specify an absolute path rather than a relative path.
94
95Configure can usually find the X include and library files automatically, but
96if it doesn't, you can use the `configure' options `--x-includes=DIR' and
97`--x-libraries=DIR' to specify their locations.
98
99The configure script provides a number of ImageMagick specific options. When
100disabling an option --disable-something is equivalent to specifying
101--enable-something=no and --without-something is equivalent to
102--with-something=no. The configure options are as follows (execute 'configure
103--help' to see all options).
104
105Optional Features:
106 --enable-ccmalloc enable 'ccmalloc' memory debug support (default disabled)
107 --enable-prof enable 'prof' profiling support (default disabled)
108 --enable-gprof enable 'gprof' profiling support (default disabled)
109 --enable-gcov enable 'gcov' profiling support (default disabled)
110 --disable-installed disable building an installed ImageMagick
111 (default enabled)
112 --disable-largefile disable support for large (64 bit) file offsets
113
114Optional Packages/Options:
115 --with-quantum-depth number of bits in a pixel quantum (default 8)
116 --with-modules enable support for dynamically loadable modules
117 --with-cache set pixel cache threshhold (defaults to available memory)
118 --without-threads disable threads support
119 --with-frozenpaths enable frozen delegate paths
120 --without-magick-plus-plus disable build/install of Magick++
121 --without-perl disable build/install of PerlMagick
122 or
123 --with-perl=PERL use specified Perl binary to configure PerlMagick
124 --with-perl-options=OPTIONS options to pass on command-line when
125 generating PerlMagick's Makefile from Makefile.PL
126 --without-bzlib disable BZLIB support
127 --without-dps disable Display Postscript support
128 --with-fpx enable FlashPIX support
129 --with-gslib enable Ghostscript library support
130 --without-jbig disable JBIG support
131 --without-jpeg disable JPEG support
132 --without-jp2 disable JPEG v2 support
133 --without-lcms disable LCMS support
134 --without-png disable PNG support
135 --without-tiff disable TIFF support
136 --without-ttf disable TrueType support
137 --without-wmf disable WMF support
138 --with-fontpath prepend to default font search path
139 --with-gs-font-dir directory containing Ghostscript fonts
140 --with-windows-font-dir directory containing MS-Windows fonts
141 --without-xml disable XML support
142 --without-zlib disable ZLIB support
143 --with-x use the X Window System
144 --with-share-path=DIR Alternate path to share directory
145 (default share/ImageMagick)
146 --with-libstdc=DIR use libstdc++ in DIR (for GNU C++)
147
148ImageMagick options represent either features to be enabled, disabled, or
149packages to be included in the build. When a feature is enabled (via
150--enable-something), it enables code already present in ImageMagick. When a
151package is enabled (via --with-something), the configure script will search for
152it, and if it is properly installed and ready to use (headers and built
153libraries are found by compiler) it will be included in the build. The
154configure script is delivered with all features disabled and all packages
155enabled. In general, the only reason to disable a package is if a package
156exists but it is unsuitable for the build (perhaps an old version or not
157compiled with the right compilation flags).
158
159Several configure options require special note:
160
161 * --enable-shared: the shared libraries are built and support for
162 loading coder and process modules is enabled. Shared libraries are
163 preferred because they allow programs to share common code, making
164 the individual programs much smaller. In addition shared libraries
165 are required in order for PerlMagick to be dynamically loaded by an
166 installed PERL (otherwise an additional PERL (PerlMagick) must be
167 installed.
168
169 ImageMagick built with delegates (see MAGICK PLUG-INS below) can pose
170 additional challenges. If ImageMagick is built using static libraries (the
171 default without --enable-shared) then delegate libraries may be built as
172 either static libraries or shared libraries. However, if ImageMagick is
173 built using shared libraries, then all delegate libraries must also be
174 built as shared libraries. Static libraries usually have the extension
175 .a, while shared libraries typically have extensions like .so, .sa, or
176 .dll. Code in shared libraries normally must compiled using a special
177 compiler option to produce Position Independent Code (PIC). The only time
178 this is not necessary is if the platform compiles code as PIC by default.
179
180 PIC compilation flags differ from vendor to vendor (gcc's is
181 -fPIC). However, you must compile all shared library source with the
182 same flag (for gcc use -fPIC rather than -fpic). While static libraries
183 are normally created using an archive tool like 'ar', shared libraries
184 are built using special linker or compiler options (e.g. -shared for gcc).
185
186 Building shared libraries often requires subtantial hand-editing of
187 Makefiles and is only recommended for those who know what they are doing.
188
189 If --enable-shared is not specified, a new PERL interpreter (PerlMagick)
190 is built which is statically linked against the PerlMagick extension. This
191 new interpreter is installed into the same directory as the ImageMagick
192 utilities. If --enable-shared is specified, the PerlMagick extension is
193 built as a dynamically loadable object which is loaded into your current
194 PERL interpreter at run-time. Use of dynamically-loaded extensions is
195 preferable over statically linked extensions so --enable-shared should
196 be specified if possible (note that all libraries used with ImageMagick
197 must be shared libraries!).
198
199 * --disable-static: static archive libraries (with extension .a)
200 are not built. If you are building shared libraries, there is little
201 value to building static libraries. Reasons to build static libraries
202 include: 1) they can be easier to debug; 2) the clients do not have
203 external dependencies (i.e. libMagick.so); 3) building PIC versions
204 of the delegate libraries may take additional expertise and effort; 4)
205 you are unable to build shared libraries.
206
207 * --disable-installed: By default the ImageMagick build is
208 configured to formally install into a directory tree. This is the
209 most secure and reliable way to install ImageMagick. Specifying
210 --disable-installed configures ImageMagick so that it doesn't use
211 hard-coded paths and locates support files by computing an offset path
212 from the executable (or from the location specified by the MAGICK_HOME
213 environment variable. The uninstalled configuration is ideal for binary
214 distributions which are expected to extract and run in any location.
215
216 * --with-modules: image coders and process modules are built as
217 loadable modules which are installed under the directory
218 [prefix]/lib/ImageMagick-X.X.X/modules-QN (where 'N' equals 8, 16,
219 or 32 depending on the quantum depth) in the subdirectories 'coders'
220 and 'filters' respectively. The modules build option is only available
221 in conjunction with --enable-shared. If --enable-shared is not also
222 specified, then support for building modules is disabled. Note that
223 if --enable-shared is specified, the module loader is active (allowing
224 extending an installed ImageMagick by simply copying a module into place)
225 but ImageMagick itself is not built using modules.
226
227 * --with-quantum-depth: This option allows the user to specify the
228 number of bits to use per pixel quantum (the size of the red, green,
229 blue, and alpha pixel components. For example, "--with-quantum-depth=8"
230 builds ImageMagick using 8-bit quantums. Most computer display adaptors
231 use 8-bit quantums. Currently supported arguments are 8, 16, or 32. The
232 default is 8. This option is the most important option in determining
233 the overall run-time performance of ImageMagick.
234
235 The number of bits in a quantum determines how many values it may
236 contain. Each quantum level supports 256 times as many values as the
237 previous level. The following table shows the range available for
238 various quantum sizes.
239
240 QuantumDepth Valid Range (Decimal) Valid Range (Hex)
241 8 0-255 00-FF
242 16 0-65535 0000-FFFF
243 32 0-4294967295 00000000-FFFFFFFF
244
245 Larger pixel quantums cause ImageMagick to run more slowly and to
246 require more memory. For example, using sixteen-bit pixel quantums
247 causes ImageMagick to run 15% to 50% slower (and take twice as much
248 memory) than when it is built to support eight-bit pixel quantums.
249
250 The amount of virtual memory consumed by an image can be computed by
251 the equation (QuantumDepth*Rows*Columns*5)/8. This is an important
252 consideration when resources are limited, particularly since processing
253 an image may require several images to be in memory at one time. The
254 following table shows memory consumption values for a 1024x768 image:
255
256 QuantumDepth Virtual Memory
257 8 3MB
258 16 8MB
259 32 15MB
260
261 * --without-magick-plus-plus: Disable building Magick++, the C++
262 application programming interface to ImageMagick. A suitable C++
263 compiler is required in order to build Magick++. Specify the CXX
264 configure variable to select the C++ compiler to use (default "g++"),
265 and CXXFLAGS to select the desired compiler opimization and debug flags
266 (default "-g -O2"). Antique C++ compilers will normally be rejected by
267 configure tests so specifying this option should only be necessary if
268 Magick++ fails to compile.
269
270 * --with-frozenpaths: Normally external program names are substituted
271 into the delegates.xml file without full paths. Specify this option
272 to enable saving full paths to programs using locations determined by
273 configure. This is useful for environments where programs are stored
274 under multiple paths, and users may use different PATH settings than
275 the person who builds ImageMagick.
276
277 * --without-threads: By default, the ImageMagick library is compiled
278 with multi-thread support. If this is undesireable, then specify
279 --without-threads.
280
281 * --with-cache: Specify a different image pixel cache threshold
282 using the --with-cache option. This sets the maximum amount of heap
283 memory that ImageMagick is allowed to consume before switching to using
284 memory-mapped temporary files to store raw pixel data.
285
286 * --disable-largefile: By default, ImageMagick is compiled with
287 support for large (> 2GB on a 32-bit CPU) files if the operating system
288 supports large files. All applications which use the ImageMagick library
289 must then also include support for large files. By disabling support for
290 large files via --disable-largefile, dependent applications do not require
291 special compilation options for large files in order to use the library.
292
293 * --with-perl: If the argument --with-perl=/path/to/perl is supplied,
294 then /path/to/perl will be taken as the PERL interpreter to use. This
295 is important in case the 'perl' executable in your PATH is not PERL5,
296 or is not the PERL you want to use.
297
298 * --with-perl-options: The PerlMagick module is normally installed
299 using the Perl interpreter's installation PREFIX, rather than
300 ImageMagick's. If ImageMagick's installation prefix is not the same
301 as PERL's PREFIX, then you may find that PerlMagick's 'make install'
302 step tries to install into a directory tree that you don't have write
303 permissions to. This is common when PERL is delivered with the operating
304 system or on Internet Service Provider (ISP) web servers. If you want
305 PerlMagick to install elsewhere, then provide a PREFIX option to PERL's
306 configuration step via "--with-perl-options=PREFIX=/some/place". Other
307 options accepted by MakeMaker are 'LIB', 'LIBPERL_A', 'LINKTYPE',
308 and 'OPTIMIZE'. See the ExtUtils::MakeMaker(3) manual page for more
309 information on configuring PERL extensions.
310
311 * --without-x: By default, ImageMagick uses the X11 delegate libraries if
312 they are available. When --without-x is specified, use of X11 is disabled.
313 The display, animate, and import sub-commands are not included. The
314 remaining sub-commands have reduced functionality such as no access to X11
315 fonts (consider using Postscript or TrueType fonts instead).
316
317 * --with-gs-font-dir: Specify the directory containing the
318 Ghostscript Postscript Type 1 font files (e.g. "n022003l.pfb") so
319 that they can be rendered using the FreeType library. If the font
320 files are installed using the default Ghostscript installation paths
321 (${prefix}/share/ghostscript/fonts), they should be discovered
322 automatically by configure and specifying this option is not
323 necessary. Specify this option if the Ghostscript fonts fail to be
324 located automatically, or the location needs to be overridden.
325
326 * --with-windows-font-dir: Specify the directory containing
327 MS-Windows-compatible fonts. This is not necessary when ImageMagick is
328 running under MS-Windows.
329
330 After you install ImageMagick, install PerlMagick with these commands:
331
332 cd ImageMagick-6.5.4
333 cd PerlMagick
334 perl Makefile.PL
335 make
336 make install
337
338----
339
340Mac OS X-specific Build instructions
341
342Perform these steps as an administrator or with the sudo command:
343
344 * Install Fink. The default setup creates a /sw folder on your main hard
345 * drive. Make sure /sw/bin is in your path.
346 * Install the latest Xcode from Apple.
347 * Create a symbolic link in /Developer/SDKs/MacOSX10.4u.sdk/ to /sw:
348
349 cd /Developer/SDKs/MacOSX10.4u.sdk
350 ln -s sw /sw
351
352 * Use Fink, or FinkCommander to install any delegate libraries you
353 * require, for example:
354
355 fink install libjpeg
356
357As a regular user or administrator:
358
359 * Download the ImageMagick source distribution.
360 * Unpack and change into the top-level ImageMagick directory:
361
362 tar xvfz ImageMagick-6.3.3-0.tar.gz
363 cd ImageMagick-6.3.3
364
365 * Choose an architecture and set your CFLAGS environment variable. Here we
366 * set CFLAGS for an Intel build:
367
368 export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch
369i386 -I/sw/include/"
370
371 * Set your LDFLAGS environment variable to:
372
373 export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk/,-L/sw/lib/"
374
375 * Configure ImageMagick:
376
377 ./configure --prefix=/sw --with-quantum-depth=16 \
378 --disable-dependency-tracking --with-x=yes \
379 --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib/ \
380 --without-perl
381
382 * Build ImageMagick:
383
384 make
385
386 * Install ImageMagick:
387
388 sudo make install
389
390 * To test the ImageMagick GUI, start X11 and in a new shell and type:
391
392 display -display :0
393
394An alterative method is to download and build ImageMagick with MacPorts.
395Download and install MacPorts and type the following command:
396
397 sudo port install ImageMagick
398
399This not only installs ImageMagick but includes many of the delegate libraries
400such as JPEG and FreeType.
401
402----
403
404Building under Cygwin
405
406 ImageMagick may be built under the Windows '95-XP Cygwin Unix-emulation
407 environment available for free from
408
409 http://www.cygwin.com/
410
411 X11R6 for Cygwin is available from
412
413 http://xfree86.cygwin.com/
414
415 We recommended that the X11R6 package be installed since this enables
416 ImageMagick's X11 support (animate, display, and import sub-commands will
417 work) and it includes the Freetype v2 DLL required to support TrueType
418 and Postscript Type 1 fonts. Make sure that /usr/X11R6/bin is in your PATH
419 prior to running the configure program.
420
421 If you are using Cygwin version 1.3.9 or later, you can specify the configure
422 option '--enable-shared' to build Cygwin DLLs. This option is required if
423 you want to build PerlMagick under Cygwin because Cygwin does not provide the
424 libperl.a static library required to create a static PerlMagick. Note that
425 since C++ exceptions do not currently work properly when thrown from a DLL,
426 the Magick++ library is always built as a static library. Be sure to not
427 specify --disable-static if you are building the Magick++ library since that
428 would surely lead to problems.
429
430----
431
432Building under MinGW & MSYS
433
434 ImageMagick may be built using the free MinGW ("Minimalistic GNU for
435 Windows") package version 1.1, available from
436
437 http://www.mingw.org
438
439 which consists of a GNU-based (e.g. gcc) compilation toolset plus headers
440 and libraries required to build programs which are entirely based on
441 standard Microsoft Windows DLLs. MSYS provides a Unix-like console shell
442 window with sufficient functionality to run the ImageMagick configure
443 script and execute make.
444
445 Unlike the Cygwin build which creates programs based on a Unix-emulation
446 DLL, and which uses Unix-style paths to access Windows files, the MinGW
447 build creates native Windows console applications similar to the Visual
448 C++ build.
449
450 Please note that since the MinGW build is very new, some aspects of the
451 installation may vary from Windows user's expectations, and that only a
452 static build (no DLLs or modules) is currently supported.
453
454 Once MinGW & MSYS have been installed, start the MSYS console (via the
455 MSYS icon on the Windows desktop) and follow the Unix configure and build
456 instructions. Note that the default installation prefix is "/usr/local"
457 which installs the package into a MSYS directory. To install outside
458 of the MSYS directory tree, you may specify an installation prefix like
459 "/c/ImageMagick" which causes the package to be installed under the Windows
460 directory "C:\ImageMagick". The installation directory structure will look
461 very much like the Unix installation layout (e.g. "C:\ImageMagick\bin",
462 "C:\ImageMagick\lib", "C:\ImageMagick\share", etc.). Any additional
463 delegate libraries (e.g. libpng) will need to be built under MinGW in
464 order to be used.
465
466----
467
468Dealing with configuration failures:
469
470 While configure is designed to ease installation of ImageMagick, it often
471 discovers problems that would otherwise be encountered later when compiling
472 ImageMagick. The configure script tests for headers and libraries by
473 executing the compiler (CC) with the specified compilation flags (CFLAGS),
474 pre-processor flags (CPPFLAGS), and linker flags (LDFLAGS). Any errors are
475 logged to the file 'config.log'. If configure fails to discover a header
476 or library please review this log file to determine why, however, please
477 be aware that *errors in the config.log are normal* because configure
478 works by trying something and seeing if it fails. An error in config.log
479 is only a problem if the test should have passed on your system. After
480 taking corrective action, be sure to remove the 'config.cache' file before
481 running configure so that configure will re-inspect the environment rather
482 than using cached values.
483
484 Common causes of configure failures are: 1) a delegate header is not in the
485 header include path (CPPFLAGS -I option); 2) a delegate library is not in
486 the linker search/run path (LDFLAGS -L/-R option); 3) a delegate library
487 is missing a function (old version?); 4) compilation environment is faulty.
488
489 If all reasonable corrective actions have been tried and the problem appears
490 be due to a flaw in the configure script, please send a bug report to the
491 ImageMagick Defect Support Forum at
492 http://studio.imagemagick.org/magick/viewforum.php?f=3. All bug reports
493 should contain the operating system type (as reported by 'uname -a') and the
494 compiler/compiler-version. A copy of the configure script output and/or the
495 config.log file may be valuable in order to find the problem. If you send a
496 config.log, please also send a script of the configure output and a
497 description of what you expected to see (and why) so the failure you are
498 observing can be identified and resolved.
499
500----
501
502Makefile Build Targets
503
504 Once ImageMagick is configured, these standard build targets are
505 available from the generated Makefiles:
506
507 * Build the package
508
509 make
510
511 * Install the package
512
513 make install
514
515 * Run tests using the installed ImageMagick ('make install' must be done
516 first!).
517
518 make check
519
520 * Remove everything in the build directory created by 'make'.
521
522 make clean
523
524 * Remove everything in the build directory created by 'configure' and 'make'.
525 This is useful if you want to start over from scratch.
526
527 make distclean
528
529 * Remove all files from the system which are (or would be) installed by
530 'make install' using the current configuration. Note that this target is
531 imperfect for PerlMagick since Perl no longer supports an 'uninstall' target.
532
533 make uninstall
534
535----
536
537Build & Install:
538
539 Now that ImageMagick is configured, type
540
541 make
542
543 to build the package and
544
545 make install
546
547 to install it.
548
549----
550
551Verifying The Build:
552
553 To confirm your installation of the ImageMagick distribution was successful,
554 ensure that the installation directory is in your executable search path and
555 type:
556
557 display
558
559 The ImageMagick logo is displayed on your X11 display.
560
561 If the image colors are not correct use this command:
562
563 display -visual default
564
565 For a more serious test, you may run the ImageMagick test suite by
566 typing
567
568 make check
569
570 Note that due to differences between the developer's environment and
571 your own it is possible that some tests may be indicated as failed even
572 though the results are ok. Differences between the developer's environment
573 and your own may include the compiler, the CPU type, and the library
574 versions used. The ImageMagick developers use the current release of all
575 dependent libraries.