]> granicus.if.org Git - libjpeg-turbo/blob - BUILDING.md
BUILDING.md: Restore autotools processing instr.
[libjpeg-turbo] / BUILDING.md
1 Building on Un*x Platforms (including Cygwin and OS X)
2 =======================================================
3
4
5 Build Requirements
6 ------------------
7
8 - autoconf 2.56 or later
9
10 - automake 1.7 or later
11
12 - libtool 1.4 or later
13   * If using Xcode 4.3 or later on OS X, autoconf and automake are no longer
14     provided.  The easiest way to obtain them is from
15     [MacPorts](http://www.MacPorts.org).
16
17 - NASM or YASM (if building x86 or x86-64 SIMD extensions)
18   * NASM 0.98, or 2.01 or later is required for an x86 build (0.99 and 2.00 do
19     not work properly with libjpeg-turbo's x86 SIMD code.)
20   * NASM 2.00 or later is required for an x86-64 build.
21   * NASM 2.07, or 2.11.09 or later is required for an x86-64 Mac build
22     (2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code when
23     building macho64 objects.)  NASM or YASM can be obtained from
24     [MacPorts](http://www.MacPorts.org).
25
26   The binary RPMs released by the NASM project do not work on older Linux
27   systems, such as Red Hat Enterprise Linux 4.  On such systems, you can
28    easily build and install NASM from a source RPM by downloading one of the
29   SRPMs from
30
31   http://www.nasm.us/pub/nasm/releasebuilds
32
33   and executing the following as root:
34
35         ARCH=`uname -m`
36         rpmbuild --rebuild nasm-{version}.src.rpm
37         rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
38
39   NOTE: the NASM build will fail if texinfo is not installed.
40
41 - GCC v4.1 (or later) or clang recommended for best performance
42
43 - If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
44   required.  Some systems, such as Solaris 10 and later and Red Hat Enterprise
45   Linux 5 and later, have this pre-installed.  On OS X 10.5 and later, it will
46   be necessary to install the Java Developer Package, which can be downloaded
47   from http://developer.apple.com/downloads (Apple ID required.)  For systems
48   that do not have a JDK installed, you can obtain the Oracle Java Development
49   Kit from http://www.java.com.
50
51
52 Out-of-Tree Builds
53 ------------------
54
55 Binary objects, libraries, and executables are generated in the same directory
56 from which `configure` was executed (the "binary directory"), and this
57 directory need not necessarily be the same as the libjpeg-turbo source
58 directory.  You can create multiple independent binary directories, in which
59 different versions of libjpeg-turbo can be built from the same source tree
60 using different compilers or settings.  In the sections below,
61 *{build_directory}* refers to the binary directory, whereas
62 *{source_directory}* refers to the libjpeg-turbo source directory.  For in-tree
63 builds, these directories are the same.
64
65
66 Building libjpeg-turbo
67 ----------------------
68
69 The following procedure will build libjpeg-turbo on Linux, FreeBSD, Cygwin, and
70 Solaris/x86 systems (on Solaris, this generates a 32-bit library.  See below
71 for 64-bit build instructions.)
72
73     cd {source_directory}
74     autoreconf -fiv
75     cd {build_directory}
76     sh {source_directory}/configure [additional configure flags]
77     make
78
79 NOTE: Running autoreconf in the source directory is not necessary if building
80 libjpeg-turbo from one of the official release tarballs.
81
82 This will generate the following files under .libs/:
83
84 **libjpeg.a**
85 Static link library for the libjpeg API
86
87 **libjpeg.so.{version}** (Linux, Unix)
88 **libjpeg.{version}.dylib** (OS X)
89 **cygjpeg-{version}.dll** (Cygwin)
90 Shared library for the libjpeg API
91
92 By default, *{version}* is 62.1.0, 7.1.0, or 8.0.2, depending on whether
93 libjpeg v6b (default), v7, or v8 emulation is enabled.  If using Cygwin,
94 *{version}* is 62, 7, or 8.
95
96 **libjpeg.so** (Linux, Unix)
97 **libjpeg.dylib** (OS X)
98 Development symlink for the libjpeg API
99
100 **libjpeg.dll.a** (Cygwin)
101 Import library for the libjpeg API
102
103 **libturbojpeg.a**
104 Static link library for the TurboJPEG API
105
106 **libturbojpeg.so.0.1.0** (Linux, Unix)
107 **libturbojpeg.0.1.0.dylib** (OS X)
108 **cygturbojpeg-0.dll** (Cygwin)
109 Shared library for the TurboJPEG API
110
111 **libturbojpeg.so** (Linux, Unix)
112 **libturbojpeg.dylib** (OS X)
113 Development symlink for the TurboJPEG API
114
115 **libturbojpeg.dll.a** (Cygwin)
116 Import library for the TurboJPEG API
117
118
119 ### libjpeg v7 or v8 API/ABI Emulation
120
121 Add `--with-jpeg7` to the `configure` command line to build a version of
122 libjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add `--with-jpeg8`
123 to the `configure` command to build a version of libjpeg-turbo that is
124 API/ABI-compatible with libjpeg v8.  See [README.md](README.md) for more
125 information on libjpeg v7 and v8 emulation.
126
127
128 ### In-Memory Source/Destination Managers
129
130 When using libjpeg v6b or v7 API/ABI emulation, add `--without-mem-srcdst` to
131 the `configure` command line to build a version of libjpeg-turbo that lacks the
132 `jpeg_mem_src()` and `jpeg_mem_dest()` functions.  These functions were not
133 part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
134 conformance with those APIs.  See [README.md](README.md) for more information.
135
136
137 ### Arithmetic Coding Support
138
139 Since the patent on arithmetic coding has expired, this functionality has been
140 included in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
141 based on the implementation in libjpeg v8, but it works when emulating libjpeg
142 v7 or v6b as well.  The default is to enable both arithmetic encoding and
143 decoding, but those who have philosophical objections to arithmetic coding can
144 add `--without-arith-enc` or `--without-arith-dec` to the `configure` command
145 line to disable encoding or decoding (respectively.)
146
147
148 ### TurboJPEG Java Wrapper
149
150 Add `--with-java` to the `configure` command line to incorporate an optional
151 Java Native Interface wrapper into the TurboJPEG shared library and build the
152 Java front-end classes to support it.  This allows the TurboJPEG shared library
153 to be used directly from Java applications.  See [java/README](java/README) for
154 more details.
155
156 You can set the `JAVAC`, `JAR`, and `JAVA` configure variables to specify
157 alternate commands for javac, jar, and java (respectively.)  You can also
158 set the `JAVACFLAGS` configure variable to specify arguments that should be
159 passed to the Java compiler when building the front-end classes, and
160 `JNI_CFLAGS` to specify arguments that should be passed to the C compiler when
161 building the JNI wrapper.  Run `configure --help` for more details.
162
163
164 Installing libjpeg-turbo
165 ------------------------
166
167 If you intend to install these libraries and the associated header files, then
168 replace 'make' in the instructions above with
169
170     make install prefix={base dir} libdir={library directory}
171
172 For example,
173
174     make install prefix=/usr/local libdir=/usr/local/lib64
175
176 will install the header files in /usr/local/include and the library files in
177 /usr/local/lib64.  If `prefix` and `libdir` are not specified, then the default
178 is to install the header files in /opt/libjpeg-turbo/include and the library
179 files in /opt/libjpeg-turbo/lib32 (32-bit) or /opt/libjpeg-turbo/lib64
180 (64-bit.)
181
182 NOTE: You can specify a prefix of /usr and a libdir of, for instance,
183 /usr/lib64 to overwrite the system's version of libjpeg.  If you do this,
184 however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before
185 overwriting it.  It is recommended that you instead install libjpeg-turbo into
186 a non-system directory and manipulate the `LD_LIBRARY_PATH` or create symlinks
187 to force applications to use libjpeg-turbo instead of libjpeg.  See
188 [README.md](README.md) for more information.
189
190
191 Build Recipes
192 -------------
193
194
195 ### 32-bit Build on 64-bit Linux
196
197 Add
198
199     --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
200
201 to the `configure` command line.
202
203
204 ### 64-bit Build on 64-bit OS X
205
206 Add
207
208     --host x86_64-apple-darwin NASM=/opt/local/bin/nasm
209
210 to the `configure` command line.  NASM 2.07 or later from MacPorts must be
211 installed.
212
213
214 ### 32-bit Build on 64-bit OS X
215
216 Add
217
218     --host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32
219
220 to the `configure` command line.
221
222
223 ### 64-bit Backward-Compatible Build on 64-bit OS X
224
225 Add
226
227     --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
228       CFLAGS='-mmacosx-version-min=10.5 -O3' \
229       LDFLAGS='-mmacosx-version-min=10.5'
230
231 to the `configure` command line.  NASM 2.07 or later from MacPorts must be
232 installed.
233
234
235 ### 32-bit Backward-Compatible Build on OS X
236
237 Add
238
239     --host i686-apple-darwin \
240       CFLAGS='-mmacosx-version-min=10.5 -O3 -m32' \
241       LDFLAGS='-mmacosx-version-min=10.5 -m32'
242
243 to the `configure` command line.
244
245
246 ### 64-bit Build on 64-bit Solaris
247
248 Add
249
250     --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
251
252 to the `configure` command line.
253
254
255 ### 32-bit Build on 64-bit FreeBSD
256
257 Add
258
259     --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
260       LDFLAGS='-B/usr/lib32'
261
262 to the `configure` command line.  NASM 2.07 or later from FreeBSD ports must be
263 installed.
264
265
266 ### Oracle Solaris Studio
267
268 Add
269
270     CC=cc
271
272 to the `configure` command line.  libjpeg-turbo will automatically be built
273 with the maximum optimization level (-xO5) unless you override `CFLAGS`.
274
275 To build a 64-bit version of libjpeg-turbo using Oracle Solaris Studio, add
276
277     --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
278
279 to the `configure` command line.
280
281
282 ### MinGW Build on Cygwin
283
284 Use CMake (see recipes below)
285
286
287 ARM Support
288 -----------
289
290 This release of libjpeg-turbo can use ARM NEON SIMD instructions to accelerate
291 JPEG compression/decompression by approximately 2-4x on ARMv7 and later
292 platforms.  If libjpeg-turbo is configured on an ARM Linux platform, then the
293 build system will automatically include the NEON SIMD routines, if they are
294 supported.  Build instructions for other ARM-based platforms follow.
295
296
297 ### Building libjpeg-turbo for iOS
298
299 iOS platforms, such as the iPhone and iPad, use ARM processors, some of which
300 support NEON instructions.  Additional steps are required in order to build
301 libjpeg-turbo for these platforms.
302
303
304 #### Additional build requirements
305
306 - [gas-preprocessor.pl]
307   (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl)
308   should be installed in your `PATH`.
309
310
311 #### ARM 32-bit Build (Xcode 4.6.x and earlier, LLVM-GCC)
312
313 Set the following shell variables for simplicity:
314
315   *Xcode 4.2 and earlier*
316
317     IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform`
318
319   *Xcode 4.3 and later*
320
321     IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
322
323   *All Xcode versions*
324
325     IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
326     IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
327
328   *ARMv6 (code will run on all iOS devices, not SIMD-accelerated)*
329   [NOTE: Requires Xcode 4.4.x or earlier]
330
331     IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
332
333   *ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer)*
334
335     IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon"
336
337   *ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer)*
338   [NOTE: Requires Xcode 4.5 or later]
339
340     IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
341
342 Follow the procedure under "Building libjpeg-turbo" above, adding
343
344     --host arm-apple-darwin10 \
345       CC="$IOS_GCC" LD="$IOS_GCC" \
346       CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
347       LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS"
348
349 to the `configure` command line.
350
351
352 #### ARM 32-bit Build (Xcode 5.0.x and later, Clang)
353
354 Set the following shell variables for simplicity:
355
356     IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
357     IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
358     IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
359
360   *ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer)*
361
362     IOS_CFLAGS="-arch armv7"
363
364   *ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer)*
365
366     IOS_CFLAGS="-arch armv7s"
367
368 Follow the procedure under "Building libjpeg-turbo" above, adding
369
370     --host arm-apple-darwin10 \
371       CC="$IOS_GCC" LD="$IOS_GCC" \
372       CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
373       LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" \
374       CCASFLAGS="-no-integrated-as $IOS_CFLAGS"
375
376 to the `configure` command line.
377
378
379 #### ARMv8 64-bit Build (Xcode 5.0.x and later, Clang)
380
381 Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer.
382
383 Set the following shell variables for simplicity:
384
385     IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
386     IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
387     IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
388     IOS_CFLAGS="-arch arm64"
389
390 Follow the procedure under "Building libjpeg-turbo" above, adding
391
392     --host aarch64-apple-darwin \
393       CC="$IOS_GCC" LD="$IOS_GCC" \
394       CFLAGS="-isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
395       LDFLAGS="-isysroot $IOS_SYSROOT $IOS_CFLAGS"
396
397 to the `configure` command line.
398
399
400 NOTE:  You can also add `-miphoneos-version-min={version}` to `$IOS_CFLAGS`
401 above in order to support older versions of iOS than the default version
402 supported by the SDK.
403
404 Once built, lipo can be used to combine the ARMv6, v7, v7s, and/or v8 variants
405 into a universal library.
406
407
408 ### Building libjpeg-turbo for Android
409
410 Building libjpeg-turbo for Android platforms requires the Android NDK
411 (https://developer.android.com/tools/sdk/ndk) and autotools.  The following is
412 a general recipe script that can be modified for your specific needs.
413
414     # Set these variables to suit your needs
415     NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk}
416     BUILD_PLATFORM={the platform name for the NDK package you installed--
417       for example, "windows-x86" or "linux-x86_64"}
418     TOOLCHAIN_VERSION={"4.6", "4.8", etc.  This corresponds to a toolchain
419       directory under ${NDK_PATH}/toolchains/.}
420     ANDROID_VERSION={The minimum version of Android to support-- for example,
421       "9", "19", etc.}
422
423     HOST=arm-linux-androideabi
424     TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
425     SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
426     ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
427     ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
428       -fstrict-aliasing --sysroot=${SYSROOT}"
429     export CPP=${TOOLCHAIN}/bin/${HOST}-cpp
430     export AR=${TOOLCHAIN}/bin/${HOST}-ar
431     export AS=${TOOLCHAIN}/bin/${HOST}-as
432     export NM=${TOOLCHAIN}/bin/${HOST}-nm
433     export CC=${TOOLCHAIN}/bin/${HOST}-gcc
434     export LD=${TOOLCHAIN}/bin/${HOST}-ld
435     export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib
436     export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump
437     export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
438     cd {build_directory}
439     sh {source_directory}/configure --host=${HOST} \
440       CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3" \
441       CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \
442       LDFLAGS="${ANDROID_CFLAGS}" --with-simd ${1+"$@"}
443     make
444
445
446 Building on Windows (Visual C++ or MinGW)
447 =========================================
448
449
450 Build Requirements
451 ------------------
452
453 - [CMake](http://www.cmake.org) v2.8.8 or later
454
455 - Microsoft Visual C++ 2005 or later
456
457   If you don't already have Visual C++, then the easiest way to get it is by
458   installing the Windows SDK:
459
460   http://msdn.microsoft.com/en-us/windows/bb980924.aspx
461
462   The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
463   everything necessary to build libjpeg-turbo.
464
465   * You can also use Microsoft Visual Studio Express Edition, which is a free
466     download.  (NOTE: versions prior to 2012 can only be used to build 32-bit
467     code.)
468   * If you intend to build libjpeg-turbo from the command line, then add the
469     appropriate compiler and SDK directories to the `INCLUDE`, `LIB`, and
470     `PATH` environment variables.  This is generally accomplished by
471     executing `vcvars32.bat` or `vcvars64.bat` and `SetEnv.cmd`.
472     `vcvars32.bat` and `vcvars64.bat` are part of Visual C++ and are located in
473     the same directory as the compiler.  `SetEnv.cmd` is part of the Windows
474     SDK.  You can pass optional arguments to `SetEnv.cmd` to specify a 32-bit
475     or 64-bit build environment.
476
477 ... OR ...
478
479 - MinGW
480
481   MinGW-builds (http://sourceforge.net/projects/mingwbuilds/) or
482   tdm-gcc (http://tdm-gcc.tdragon.net/) recommended if building on a Windows
483   machine.  Both distributions install a Start Menu link that can be used to
484   launch a command prompt with the appropriate compiler paths automatically
485   set.
486
487 - [NASM](http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
488   a 64-bit build)
489
490 - If building the TurboJPEG Java wrapper, JDK 1.5 or later is required.  This
491   can be downloaded from http://www.java.com.
492
493
494 Out-of-Tree Builds
495 ------------------
496
497 Binary objects, libraries, and executables are generated in the same directory
498 from which `cmake` was executed (the "binary directory"), and this directory
499 need not necessarily be the same as the libjpeg-turbo source directory.  You
500 can create multiple independent binary directories, in which different versions
501 of libjpeg-turbo can be built from the same source tree using different
502 compilers or settings.  In the sections below, *{build_directory}* refers to
503 the binary directory, whereas *{source_directory}* refers to the libjpeg-turbo
504 source directory.  For in-tree builds, these directories are the same.
505
506
507 Building libjpeg-turbo
508 ----------------------
509
510
511 ### Visual C++ (Command Line)
512
513     cd {build_directory}
514     cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
515     nmake
516
517 This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
518 on which version of cl.exe is in the `PATH`.
519
520 The following files will be generated under *{build_directory}*:
521
522 **jpeg-static.lib**
523 Static link library for the libjpeg API
524
525 **sharedlib/jpeg{version}.dll**
526 DLL for the libjpeg API
527
528 **sharedlib/jpeg.lib**
529 Import library for the libjpeg API
530
531 **turbojpeg-static.lib**
532 Static link library for the TurboJPEG API
533
534 **turbojpeg.dll**
535 DLL for the TurboJPEG API
536
537 **turbojpeg.lib**
538 Import library for the TurboJPEG API
539
540 *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
541 v8 emulation is enabled.
542
543
544 ### Visual C++ (IDE)
545
546 Choose the appropriate CMake generator option for your version of Visual Studio
547 (run `cmake` with no arguments for a list of available generators.)  For
548 instance:
549
550     cd {build_directory}
551     cmake -G "Visual Studio 10" {source_directory}
552
553 NOTE:  Add "Win64" to the generator name (for example, "Visual Studio 10
554 Win64") to build a 64-bit version of libjpeg-turbo.  Recent versions of CMake
555 no longer document that.  A separate build directory must be used for 32-bit
556 and 64-bit builds.
557
558 You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
559 configurations in that project ("Debug", "Release", etc.) to generate a full
560 build of libjpeg-turbo.
561
562 This will generate the following files under *{build_directory}*:
563
564 **{configuration}/jpeg-static.lib**
565 Static link library for the libjpeg API
566
567 **sharedlib/{configuration}/jpeg{version}.dll**
568 DLL for the libjpeg API
569
570 **sharedlib/{configuration}/jpeg.lib**
571 Import library for the libjpeg API
572
573 **{configuration}/turbojpeg-static.lib**
574 Static link library for the TurboJPEG API
575
576 **{configuration}/turbojpeg.dll**
577 DLL for the TurboJPEG API
578
579 **{configuration}/turbojpeg.lib**
580 Import library for the TurboJPEG API
581
582 *{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending
583 on the configuration you built in the IDE, and *{version}* is 62, 7, or 8,
584 depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
585
586
587 ### MinGW
588
589 NOTE: This assumes that you are building on a Windows machine.  If you are
590 cross-compiling on a Linux/Unix machine, then see "Build Recipes" below.
591
592     cd {build_directory}
593     cmake -G "MinGW Makefiles" {source_directory}
594     mingw32-make
595
596 This will generate the following files under *{build_directory}*:
597
598 **libjpeg.a**
599 Static link library for the libjpeg API
600
601 **sharedlib/libjpeg-{version}.dll**
602 DLL for the libjpeg API
603
604 **sharedlib/libjpeg.dll.a**
605 Import library for the libjpeg API
606
607 **libturbojpeg.a**
608 Static link library for the TurboJPEG API
609
610 **libturbojpeg.dll**
611 DLL for the TurboJPEG API
612
613 **libturbojpeg.dll.a**
614 Import library for the TurboJPEG API
615
616 *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
617 v8 emulation is enabled.
618
619
620 ### Debug Build
621
622 Add `-DCMAKE_BUILD_TYPE=Debug` to the `cmake` command line.  Or, if building
623 with NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default
624 with NMake.)
625
626
627 ### libjpeg v7 or v8 API/ABI Emulation
628
629 Add `-DWITH_JPEG7=1` to the `cmake` command line to build a version of
630 libjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add `-DWITH_JPEG8=1`
631 to the `cmake` command line to build a version of libjpeg-turbo that is
632 API/ABI-compatible with libjpeg v8.  See [README.md](README.md) for more
633 information on libjpeg v7 and v8 emulation.
634
635
636 ### In-Memory Source/Destination Managers
637
638 When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
639 the `cmake` command line to build a version of libjpeg-turbo that lacks the
640 `jpeg_mem_src()` and `jpeg_mem_dest()` functions.  These functions were not
641 part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
642 conformance with those APIs.  See [README.md](README.md) for more information.
643
644
645 ### Arithmetic Coding Support
646
647 Since the patent on arithmetic coding has expired, this functionality has been
648 included in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
649 based on the implementation in libjpeg v8, but it works when emulating libjpeg
650 v7 or v6b as well.  The default is to enable both arithmetic encoding and
651 decoding, but those who have philosophical objections to arithmetic coding can
652 add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the `cmake` command line to
653 disable encoding or decoding (respectively.)
654
655
656 ### TurboJPEG Java Wrapper
657
658 Add `-DWITH_JAVA=1` to the `cmake` command line to incorporate an optional Java
659 Native Interface wrapper into the TurboJPEG shared library and build the Java
660 front-end classes to support it.  This allows the TurboJPEG shared library to
661 be used directly from Java applications.  See [java/README](java/README) for
662 more details.
663
664 If you are using CMake 2.8, you can set the `Java_JAVAC_EXECUTABLE`,
665 `Java_JAVA_EXECUTABLE`, and `Java_JAR_EXECUTABLE` CMake variables to specify
666 alternate commands or locations for javac, jar, and java (respectively.)  You
667 can also set the `JAVACFLAGS` CMake variable to specify arguments that should
668 be passed to the Java compiler when building the front-end classes.
669
670
671 Installing libjpeg-turbo
672 ------------------------
673
674 You can use the build system to install libjpeg-turbo into a directory of your
675 choosing (as opposed to creating an installer.)  To do this, add:
676
677     -DCMAKE_INSTALL_PREFIX={install_directory}
678
679 to the cmake command line.
680
681 For example,
682
683     cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
684       -DCMAKE_INSTALL_PREFIX=c:\libjpeg-turbo {source_directory}
685     nmake install
686
687 will install the header files in c:\libjpeg-turbo\include, the library files
688 in c:\libjpeg-turbo\lib, the DLL's in c:\libjpeg-turbo\bin, and the
689 documentation in c:\libjpeg-turbo\doc.
690
691
692 Build Recipes
693 -------------
694
695
696 ### 64-bit MinGW Build on Cygwin
697
698     cd {build_directory}
699     CC=/usr/bin/x86_64-w64-mingw32-gcc \
700       cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
701       -DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe \
702       {source_directory}
703     make
704
705 This produces a 64-bit build of libjpeg-turbo that does not depend on
706 cygwin1.dll or other Cygwin DLL's.  The mingw64-x86\_64-gcc-core and
707 mingw64-x86\_64-gcc-g++ packages (and their dependencies) must be installed.
708
709
710 ### 32-bit MinGW Build on Cygwin
711
712      cd {build_directory}
713      CC=/usr/bin/i686-w64-mingw32-gcc \
714        cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
715        -DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres.exe \
716        {source_directory}
717      make
718
719 This produces a 32-bit build of libjpeg-turbo that does not depend on
720 cygwin1.dll or other Cygwin DLL's.  The mingw64-i686-gcc-core and
721 mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
722
723
724 ### MinGW Build on Linux
725
726     cd {build_directory}
727     CC={mingw_binary_path}/i386-mingw32-gcc \
728       cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
729       -DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
730       -DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
731     {source_directory}
732     make
733
734
735 Creating Release Packages
736 =========================
737
738 The following commands can be used to create various types of release packages:
739
740
741 Unix/Linux
742 ----------
743
744     make rpm
745
746 Create Red Hat-style binary RPM package.  Requires RPM v4 or later.
747
748     make srpm
749
750 This runs `make dist` to create a pristine source tarball, then creates a
751 Red Hat-style source RPM package from the tarball.  Requires RPM v4 or later.
752
753     make deb
754
755 Create Debian-style binary package.  Requires dpkg.
756
757     make dmg
758
759 Create Macintosh package/disk image.  This requires pkgbuild and
760 productbuild, which are installed by default on OS X 10.7 and later and which
761 can be obtained by installing Xcode 3.2.6 (with the "Unix Development"
762 option) on OS X 10.6.  Packages built in this manner can be installed on OS X
763 10.5 and later, but they must be built on OS X 10.6 or later.
764
765     make udmg [BUILDDIR32={32-bit build directory}]
766
767 On 64-bit OS X systems, this creates a Macintosh package and disk image that
768 contains universal i386/x86-64 binaries.  You should first configure a 32-bit
769 out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree
770 build, then run `make udmg` from the 64-bit build directory.  The build
771 system will look for the 32-bit build under *{source_directory}*/osxx86 by
772 default, but you can override this by setting the `BUILDDIR32` variable on the
773 make command line as shown above.
774
775     make iosdmg [BUILDDIR32={32-bit build directory}] \
776       [BUILDDIRARMV6={ARMv6 build directory}] \
777       [BUILDDIRARMV7={ARMv7 build directory}] \
778       [BUILDDIRARMV7S={ARMv7s build directory}] \
779       [BUILDDIRARMV8={ARMv8 build directory}]
780
781 On OS X systems, this creates a Macintosh package and disk image in which the
782 libjpeg-turbo static libraries contain ARM architectures necessary to build
783 iOS applications.  If building on an x86-64 system, the binaries will also
784 contain the i386 architecture, as with `make udmg` above.  You should first
785 configure ARMv6, ARMv7, ARMv7s, and/or ARMv8 out-of-tree builds of
786 libjpeg-turbo (see "Building libjpeg-turbo for iOS" above.)  If you are
787 building an x86-64 version of libjpeg-turbo, you should configure a 32-bit
788 out-of-tree build as well.  Next, build libjpeg-turbo as you would normally,
789 using an out-of-tree build.  When it is built, run `make iosdmg` from the
790 build directory.  The build system will look for the ARMv6 build under
791 *{source_directory}*/iosarmv6 by default, the ARMv7 build under
792 *{source_directory}*/iosarmv7 by default, the ARMv7s build under
793 *{source_directory}*/iosarmv7s by default, the ARMv8 build under
794 *{source_directory}*/iosarmv8 by default, and (if applicable) the 32-bit build
795 under *{source_directory}*/osxx86 by default, but you can override this by
796 setting the `BUILDDIR32`, `BUILDDIRARMV6`, `BUILDDIRARMV7`, `BUILDDIRARMV7S`,
797 and/or `BUILDDIRARMV8` variables on the `make` command line as shown above.
798
799 NOTE: If including an ARMv8 build in the package, then you may need to use
800 Xcode's version of lipo instead of the operating system's.  To do this, pass
801 an argument of `LIPO="xcrun lipo"` on the make command line.
802
803     make cygwinpkg
804
805 Build a Cygwin binary package.
806
807
808 Windows
809 -------
810
811 If using NMake:
812
813     cd {build_directory}
814     nmake installer
815
816 If using MinGW:
817
818     cd {build_directory}
819     make installer
820
821 If using the Visual Studio IDE, build the "installer" project.
822
823 The installer package (libjpeg-turbo[-gcc][64].exe) will be located under
824 *{build_directory}*.  If building using the Visual Studio IDE, then the
825 installer package will be located in a subdirectory with the same name as the
826 configuration you built (such as *{build_directory}*\Debug\ or
827 *{build_directory}*\Release\).
828
829 Building a Windows installer requires the Nullsoft Install System
830 (http://nsis.sourceforge.net/.)  makensis.exe should be in your `PATH`.
831
832
833 Regression testing
834 ==================
835
836 The most common way to test libjpeg-turbo is by invoking `make test` on
837 Unix/Linux platforms or `ctest` on Windows platforms, once the build has
838 completed.  This runs a series of tests to ensure that mathematical
839 compatibility has been maintained between libjpeg-turbo and libjpeg v6b.  This
840 also invokes the TurboJPEG unit tests, which ensure that the colorspace
841 extensions, YUV encoding, decompression scaling, and other features of the
842 TurboJPEG C and Java APIs are working properly (and, by extension, that the
843 equivalent features of the underlying libjpeg API are also working.)
844
845 Invoking `make testclean` or `nmake testclean` (if using NMake) or building
846 the 'testclean' target (if using the Visual Studio IDE) will clean up the
847 output images generated by `make test`.
848
849 On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java
850 wrappers can be run by invoking `make tjtest`.  These extended TurboJPEG tests
851 essentially iterate through all of the available features of the TurboJPEG APIs
852 that are not covered by the TurboJPEG unit tests (this includes the lossless
853 transform options) and compare the images generated by each feature to images
854 generated using the equivalent feature in the libjpeg API.  The extended
855 TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
856 not in the underlying libjpeg API library.