Home | History | Annotate | Download | only in libjpeg-turbo
      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 - 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 
     50 Out-of-Tree Builds
     51 ------------------
     52 
     53 Binary objects, libraries, and executables are generated in the same directory
     54 from which `configure` was executed (the "binary directory"), and this
     55 directory need not necessarily be the same as the libjpeg-turbo source
     56 directory.  You can create multiple independent binary directories, in which
     57 different versions of libjpeg-turbo can be built from the same source tree
     58 using 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
     61 builds, these directories are the same.
     62 
     63 
     64 Building libjpeg-turbo
     65 ----------------------
     66 
     67 The following procedure will build libjpeg-turbo on Linux, FreeBSD, Cygwin, and
     68 Solaris/x86 systems (on Solaris, this generates a 32-bit library.  See below
     69 for 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 
     77 NOTE: Running autoreconf in the source directory is not necessary if building
     78 libjpeg-turbo from one of the official release tarballs.
     79 
     80 This will generate the following files under .libs/:
     81 
     82 **libjpeg.a**  
     83 Static link library for the libjpeg API
     84 
     85 **libjpeg.so.{version}** (Linux, Unix)  
     86 **libjpeg.{version}.dylib** (OS X)  
     87 **cygjpeg-{version}.dll** (Cygwin)  
     88 Shared library for the libjpeg API
     89 
     90 By default, *{version}* is 62.1.0, 7.1.0, or 8.0.2, depending on whether
     91 libjpeg 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)  
     96 Development symlink for the libjpeg API
     97 
     98 **libjpeg.dll.a** (Cygwin)  
     99 Import library for the libjpeg API
    100 
    101 **libturbojpeg.a**  
    102 Static 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)  
    107 Shared library for the TurboJPEG API
    108 
    109 **libturbojpeg.so** (Linux, Unix)  
    110 **libturbojpeg.dylib** (OS X)  
    111 Development symlink for the TurboJPEG API
    112 
    113 **libturbojpeg.dll.a** (Cygwin)  
    114 Import library for the TurboJPEG API
    115 
    116 
    117 ### libjpeg v7 or v8 API/ABI Emulation
    118 
    119 Add `--with-jpeg7` to the `configure` command line to build a version of
    120 libjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add `--with-jpeg8`
    121 to the `configure` command to build a version of libjpeg-turbo that is
    122 API/ABI-compatible with libjpeg v8.  See [README.md](README.md) for more
    123 information on libjpeg v7 and v8 emulation.
    124 
    125 
    126 ### In-Memory Source/Destination Managers
    127 
    128 When using libjpeg v6b or v7 API/ABI emulation, add `--without-mem-srcdst` to
    129 the `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
    131 part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
    132 conformance with those APIs.  See [README.md](README.md) for more information.
    133 
    134 
    135 ### Arithmetic Coding Support
    136 
    137 Since the patent on arithmetic coding has expired, this functionality has been
    138 included in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
    139 based on the implementation in libjpeg v8, but it works when emulating libjpeg
    140 v7 or v6b as well.  The default is to enable both arithmetic encoding and
    141 decoding, but those who have philosophical objections to arithmetic coding can
    142 add `--without-arith-enc` or `--without-arith-dec` to the `configure` command
    143 line to disable encoding or decoding (respectively.)
    144 
    145 
    146 ### TurboJPEG Java Wrapper
    147 
    148 Add `--with-java` to the `configure` command line to incorporate an optional
    149 Java Native Interface wrapper into the TurboJPEG shared library and build the
    150 Java front-end classes to support it.  This allows the TurboJPEG shared library
    151 to be used directly from Java applications.  See [java/README](java/README) for
    152 more details.
    153 
    154 You can set the `JAVAC`, `JAR`, and `JAVA` configure variables to specify
    155 alternate commands for javac, jar, and java (respectively.)  You can also
    156 set the `JAVACFLAGS` configure variable to specify arguments that should be
    157 passed 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
    159 building the JNI wrapper.  Run `configure --help` for more details.
    160 
    161 
    162 Installing libjpeg-turbo
    163 ------------------------
    164 
    165 If you intend to install these libraries and the associated header files, then
    166 replace 'make' in the instructions above with
    167 
    168     make install prefix={base dir} libdir={library directory}
    169 
    170 For example,
    171 
    172     make install prefix=/usr/local libdir=/usr/local/lib64
    173 
    174 will 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
    176 is to install the header files in /opt/libjpeg-turbo/include and the library
    177 files in /opt/libjpeg-turbo/lib32 (32-bit) or /opt/libjpeg-turbo/lib64
    178 (64-bit.)
    179 
    180 NOTE: 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,
    182 however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before
    183 overwriting it.  It is recommended that you instead install libjpeg-turbo into
    184 a non-system directory and manipulate the `LD_LIBRARY_PATH` or create symlinks
    185 to force applications to use libjpeg-turbo instead of libjpeg.  See
    186 [README.md](README.md) for more information.
    187 
    188 
    189 Build Recipes
    190 -------------
    191 
    192 
    193 ### 32-bit Build on 64-bit Linux
    194 
    195 Add
    196 
    197     --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
    198 
    199 to the `configure` command line.
    200 
    201 
    202 ### 64-bit Build on 64-bit OS X
    203 
    204 Add
    205 
    206     --host x86_64-apple-darwin NASM=/opt/local/bin/nasm
    207 
    208 to the `configure` command line.  NASM 2.07 or later from MacPorts must be
    209 installed.
    210 
    211 
    212 ### 32-bit Build on 64-bit OS X
    213 
    214 Add
    215 
    216     --host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32
    217 
    218 to the `configure` command line.
    219 
    220 
    221 ### 64-bit Backward-Compatible Build on 64-bit OS X
    222 
    223 Add
    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 
    229 to the `configure` command line.  NASM 2.07 or later from MacPorts must be
    230 installed.
    231 
    232 
    233 ### 32-bit Backward-Compatible Build on OS X
    234 
    235 Add
    236 
    237     --host i686-apple-darwin \
    238       CFLAGS='-mmacosx-version-min=10.5 -O3 -m32' \
    239       LDFLAGS='-mmacosx-version-min=10.5 -m32'
    240 
    241 to the `configure` command line.
    242 
    243 
    244 ### 64-bit Build on 64-bit Solaris
    245 
    246 Add
    247 
    248     --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
    249 
    250 to the `configure` command line.
    251 
    252 
    253 ### 32-bit Build on 64-bit FreeBSD
    254 
    255 Add
    256 
    257     --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
    258       LDFLAGS='-B/usr/lib32'
    259 
    260 to the `configure` command line.  NASM 2.07 or later from FreeBSD ports must be
    261 installed.
    262 
    263 
    264 ### Oracle Solaris Studio
    265 
    266 Add
    267 
    268     CC=cc
    269 
    270 to the `configure` command line.  libjpeg-turbo will automatically be built
    271 with the maximum optimization level (-xO5) unless you override `CFLAGS`.
    272 
    273 To 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 
    277 to the `configure` command line.
    278 
    279 
    280 ### MinGW Build on Cygwin
    281 
    282 Use CMake (see recipes below)
    283 
    284 
    285 ARM Support
    286 -----------
    287 
    288 This release of libjpeg-turbo can use ARM NEON SIMD instructions to accelerate
    289 JPEG compression/decompression by approximately 2-4x on ARMv7 and later
    290 platforms.  If libjpeg-turbo is configured on an ARM Linux platform, then the
    291 build system will automatically include the NEON SIMD routines, if they are
    292 supported.  Build instructions for other ARM-based platforms follow.
    293 
    294 
    295 ### Building libjpeg-turbo for iOS
    296 
    297 iOS platforms, such as the iPhone and iPad, use ARM processors, some of which
    298 support NEON instructions.  Additional steps are required in order to build
    299 libjpeg-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 
    311 Set 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 
    335 Follow 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 
    342 to the `configure` command line.
    343 
    344 
    345 #### ARM 32-bit Build (Xcode 5.0.x and later, Clang)
    346 
    347 Set 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 
    361 Follow 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 
    369 to the `configure` command line.
    370 
    371 
    372 #### ARMv8 64-bit Build (Xcode 5.0.x and later, Clang)
    373 
    374 Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer.
    375 
    376 Set 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 
    383 Follow 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 
    390 to the `configure` command line.
    391 
    392 
    393 NOTE:  You can also add `-miphoneos-version-min={version}` to `$IOS_CFLAGS`
    394 above in order to support older versions of iOS than the default version
    395 supported by the SDK.
    396 
    397 Once built, lipo can be used to combine the ARMv7, v7s, and/or v8 variants into
    398 a universal library.
    399 
    400 
    401 ### Building libjpeg-turbo for Android
    402 
    403 Building libjpeg-turbo for Android platforms requires the
    404 {Android NDK}(https://developer.android.com/tools/sdk/ndk)
    405 and 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 
    445 If building for Android 4.0.x (API level < 16) or earlier, remove `-fPIE` from
    446 `CFLAGS` and `-pie` from `LDFLAGS`.
    447 
    448 
    449 Building on Windows (Visual C++ or MinGW)
    450 =========================================
    451 
    452 
    453 Build 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 
    497 Out-of-Tree Builds
    498 ------------------
    499 
    500 Binary objects, libraries, and executables are generated in the same directory
    501 from which `cmake` was executed (the "binary directory"), and this directory
    502 need not necessarily be the same as the libjpeg-turbo source directory.  You
    503 can create multiple independent binary directories, in which different versions
    504 of libjpeg-turbo can be built from the same source tree using different
    505 compilers or settings.  In the sections below, *{build_directory}* refers to
    506 the binary directory, whereas *{source_directory}* refers to the libjpeg-turbo
    507 source directory.  For in-tree builds, these directories are the same.
    508 
    509 
    510 Building 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 
    520 This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
    521 on which version of cl.exe is in the `PATH`.
    522 
    523 The following files will be generated under *{build_directory}*:
    524 
    525 **jpeg-static.lib**  
    526 Static link library for the libjpeg API
    527 
    528 **sharedlib/jpeg{version}.dll**  
    529 DLL for the libjpeg API
    530 
    531 **sharedlib/jpeg.lib**  
    532 Import library for the libjpeg API
    533 
    534 **turbojpeg-static.lib**  
    535 Static link library for the TurboJPEG API
    536 
    537 **turbojpeg.dll**  
    538 DLL for the TurboJPEG API
    539 
    540 **turbojpeg.lib**  
    541 Import library for the TurboJPEG API
    542 
    543 *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
    544 v8 emulation is enabled.
    545 
    546 
    547 ### Visual C++ (IDE)
    548 
    549 Choose the appropriate CMake generator option for your version of Visual Studio
    550 (run `cmake` with no arguments for a list of available generators.)  For
    551 instance:
    552 
    553     cd {build_directory}
    554     cmake -G "Visual Studio 10" {source_directory}
    555 
    556 NOTE:  Add "Win64" to the generator name (for example, "Visual Studio 10
    557 Win64") to build a 64-bit version of libjpeg-turbo.  Recent versions of CMake
    558 no longer document that.  A separate build directory must be used for 32-bit
    559 and 64-bit builds.
    560 
    561 You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
    562 configurations in that project ("Debug", "Release", etc.) to generate a full
    563 build of libjpeg-turbo.
    564 
    565 This will generate the following files under *{build_directory}*:
    566 
    567 **{configuration}/jpeg-static.lib**  
    568 Static link library for the libjpeg API
    569 
    570 **sharedlib/{configuration}/jpeg{version}.dll**  
    571 DLL for the libjpeg API
    572 
    573 **sharedlib/{configuration}/jpeg.lib**  
    574 Import library for the libjpeg API
    575 
    576 **{configuration}/turbojpeg-static.lib**  
    577 Static link library for the TurboJPEG API
    578 
    579 **{configuration}/turbojpeg.dll**  
    580 DLL for the TurboJPEG API
    581 
    582 **{configuration}/turbojpeg.lib**  
    583 Import library for the TurboJPEG API
    584 
    585 *{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending
    586 on the configuration you built in the IDE, and *{version}* is 62, 7, or 8,
    587 depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
    588 
    589 
    590 ### MinGW
    591 
    592 NOTE: This assumes that you are building on a Windows machine.  If you are
    593 cross-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 
    599 This will generate the following files under *{build_directory}*:
    600 
    601 **libjpeg.a**  
    602 Static link library for the libjpeg API
    603 
    604 **sharedlib/libjpeg-{version}.dll**  
    605 DLL for the libjpeg API
    606 
    607 **sharedlib/libjpeg.dll.a**  
    608 Import library for the libjpeg API
    609 
    610 **libturbojpeg.a**  
    611 Static link library for the TurboJPEG API
    612 
    613 **libturbojpeg.dll**  
    614 DLL for the TurboJPEG API
    615 
    616 **libturbojpeg.dll.a**  
    617 Import library for the TurboJPEG API
    618 
    619 *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
    620 v8 emulation is enabled.
    621 
    622 
    623 ### Debug Build
    624 
    625 Add `-DCMAKE_BUILD_TYPE=Debug` to the `cmake` command line.  Or, if building
    626 with NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default
    627 with NMake.)
    628 
    629 
    630 ### libjpeg v7 or v8 API/ABI Emulation
    631 
    632 Add `-DWITH_JPEG7=1` to the `cmake` command line to build a version of
    633 libjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add `-DWITH_JPEG8=1`
    634 to the `cmake` command line to build a version of libjpeg-turbo that is
    635 API/ABI-compatible with libjpeg v8.  See [README.md](README.md) for more
    636 information on libjpeg v7 and v8 emulation.
    637 
    638 
    639 ### In-Memory Source/Destination Managers
    640 
    641 When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
    642 the `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
    644 part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
    645 conformance with those APIs.  See [README.md](README.md) for more information.
    646 
    647 
    648 ### Arithmetic Coding Support
    649 
    650 Since the patent on arithmetic coding has expired, this functionality has been
    651 included in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
    652 based on the implementation in libjpeg v8, but it works when emulating libjpeg
    653 v7 or v6b as well.  The default is to enable both arithmetic encoding and
    654 decoding, but those who have philosophical objections to arithmetic coding can
    655 add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the `cmake` command line to
    656 disable encoding or decoding (respectively.)
    657 
    658 
    659 ### TurboJPEG Java Wrapper
    660 
    661 Add `-DWITH_JAVA=1` to the `cmake` command line to incorporate an optional Java
    662 Native Interface wrapper into the TurboJPEG shared library and build the Java
    663 front-end classes to support it.  This allows the TurboJPEG shared library to
    664 be used directly from Java applications.  See [java/README](java/README) for
    665 more details.
    666 
    667 You can set the `Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and
    668 `Java_JAR_EXECUTABLE` CMake variables to specify alternate commands or
    669 locations for javac, jar, and java (respectively.)  You can also set the
    670 `JAVACFLAGS` CMake variable to specify arguments that should be passed to the
    671 Java compiler when building the front-end classes.
    672 
    673 
    674 Installing libjpeg-turbo
    675 ------------------------
    676 
    677 You can use the build system to install libjpeg-turbo into a directory of your
    678 choosing (as opposed to creating an installer.)  To do this, add:
    679 
    680     -DCMAKE_INSTALL_PREFIX={install_directory}
    681 
    682 to the cmake command line.
    683 
    684 For example,
    685 
    686     cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
    687       -DCMAKE_INSTALL_PREFIX=c:\libjpeg-turbo {source_directory}
    688     nmake install
    689 
    690 will install the header files in c:\libjpeg-turbo\include, the library files
    691 in c:\libjpeg-turbo\lib, the DLL's in c:\libjpeg-turbo\bin, and the
    692 documentation in c:\libjpeg-turbo\doc.
    693 
    694 
    695 Build 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 
    708 This produces a 64-bit build of libjpeg-turbo that does not depend on
    709 cygwin1.dll or other Cygwin DLL's.  The mingw64-x86\_64-gcc-core and
    710 mingw64-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 
    722 This produces a 32-bit build of libjpeg-turbo that does not depend on
    723 cygwin1.dll or other Cygwin DLL's.  The mingw64-i686-gcc-core and
    724 mingw64-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 
    739 Creating Release Packages
    740 =========================
    741 
    742 The following commands can be used to create various types of release packages:
    743 
    744 
    745 Unix/Linux
    746 ----------
    747 
    748     make rpm
    749 
    750 Create Red Hat-style binary RPM package.  Requires RPM v4 or later.
    751 
    752     make srpm
    753 
    754 This runs `make dist` to create a pristine source tarball, then creates a
    755 Red Hat-style source RPM package from the tarball.  Requires RPM v4 or later.
    756 
    757     make deb
    758 
    759 Create Debian-style binary package.  Requires dpkg.
    760 
    761     make dmg
    762 
    763 Create Macintosh package/disk image.  This requires pkgbuild and
    764 productbuild, which are installed by default on OS X 10.7 and later and which
    765 can be obtained by installing Xcode 3.2.6 (with the "Unix Development"
    766 option) on OS X 10.6.  Packages built in this manner can be installed on OS X
    767 10.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 
    771 On 64-bit OS X systems, this creates a Macintosh package and disk image that
    772 contains universal i386/x86-64 binaries.  You should first configure a 32-bit
    773 out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree
    774 build, then run `make udmg` from the 64-bit build directory.  The build
    775 system will look for the 32-bit build under *{source_directory}*/osxx86 by
    776 default, but you can override this by setting the `BUILDDIR32` variable on the
    777 make 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 
    784 On OS X systems, this creates a Macintosh package and disk image in which the
    785 libjpeg-turbo static libraries contain ARM architectures necessary to build
    786 iOS applications.  If building on an x86-64 system, the binaries will also
    787 contain the i386 architecture, as with `make udmg` above.  You should first
    788 configure 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
    790 of libjpeg-turbo, you should configure a 32-bit out-of-tree build as well.
    791 Next, build libjpeg-turbo as you would normally, using an out-of-tree build.
    792 When it is built, run `make iosdmg` from the build directory.  The build system
    793 will look for the ARMv7 build under *{source_directory}*/iosarmv7 by default,
    794 the ARMv7s build under *{source_directory}*/iosarmv7s by default, the ARMv8
    795 build under *{source_directory}*/iosarmv8 by default, and (if applicable) the
    796 32-bit build under *{source_directory}*/osxx86 by default, but you can override
    797 this by setting the `BUILDDIR32`, `BUILDDIRARMV7`, `BUILDDIRARMV7S`, and/or
    798 `BUILDDIRARMV8` variables on the `make` command line as shown above.
    799 
    800 NOTE: If including an ARMv8 build in the package, then you may need to use
    801 Xcode's version of lipo instead of the operating system's.  To do this, pass
    802 an argument of `LIPO="xcrun lipo"` on the make command line.
    803 
    804     make cygwinpkg
    805 
    806 Build a Cygwin binary package.
    807 
    808 
    809 Windows
    810 -------
    811 
    812 If using NMake:
    813 
    814     cd {build_directory}
    815     nmake installer
    816 
    817 If using MinGW:
    818 
    819     cd {build_directory}
    820     make installer
    821 
    822 If using the Visual Studio IDE, build the "installer" project.
    823 
    824 The installer package (libjpeg-turbo[-gcc][64].exe) will be located under
    825 *{build_directory}*.  If building using the Visual Studio IDE, then the
    826 installer package will be located in a subdirectory with the same name as the
    827 configuration you built (such as *{build_directory}*\Debug\ or
    828 *{build_directory}*\Release\).
    829 
    830 Building a Windows installer requires the Nullsoft Install System
    831 (http://nsis.sourceforge.net/.)  makensis.exe should be in your `PATH`.
    832 
    833 
    834 Regression testing
    835 ==================
    836 
    837 The most common way to test libjpeg-turbo is by invoking `make test` on
    838 Unix/Linux platforms or `ctest` on Windows platforms, once the build has
    839 completed.  This runs a series of tests to ensure that mathematical
    840 compatibility has been maintained between libjpeg-turbo and libjpeg v6b.  This
    841 also invokes the TurboJPEG unit tests, which ensure that the colorspace
    842 extensions, YUV encoding, decompression scaling, and other features of the
    843 TurboJPEG C and Java APIs are working properly (and, by extension, that the
    844 equivalent features of the underlying libjpeg API are also working.)
    845 
    846 Invoking `make testclean` or `nmake testclean` (if using NMake) or building
    847 the 'testclean' target (if using the Visual Studio IDE) will clean up the
    848 output images generated by `make test`.
    849 
    850 On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java
    851 wrappers can be run by invoking `make tjtest`.  These extended TurboJPEG tests
    852 essentially iterate through all of the available features of the TurboJPEG APIs
    853 that are not covered by the TurboJPEG unit tests (this includes the lossless
    854 transform options) and compare the images generated by each feature to images
    855 generated using the equivalent feature in the libjpeg API.  The extended
    856 TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
    857 not in the underlying libjpeg API library.
    858