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