11 - [CMake](http://www.cmake.org) v2.8.12 or later
13 - [NASM](http://www.nasm.us) or [YASM](http://yasm.tortall.net)
14 (if building x86 or x86-64 SIMD extensions)
15 * If using NASM, 2.10 or later is required.
16 * If using NASM, 2.10 or later (except 2.11.08) is required for an x86-64 Mac
17 build (2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code
18 when building macho64 objects.) NASM or YASM can be obtained from
19 [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
20 * If using YASM, 1.2.0 or later is required.
21 - NOTE: Currently, if it is desirable to hide the SIMD function symbols in
22 Mac executables or shared libraries that statically link with
23 libjpeg-turbo, then YASM must be used when building libjpeg-turbo.
24 * If building on Windows, **nasm.exe**/**yasm.exe** should be in your `PATH`.
26 The binary RPMs released by the NASM project do not work on older Linux
27 systems, such as Red Hat Enterprise Linux 5. On such systems, you can easily
28 build and install NASM from a source RPM by downloading one of the SRPMs from
30 <http://www.nasm.us/pub/nasm/releasebuilds>
32 and executing the following as root:
35 rpmbuild --rebuild nasm-{version}.src.rpm
36 rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
38 NOTE: the NASM build will fail if texinfo is not installed.
41 ### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin)
43 - GCC v4.1 (or later) or Clang recommended for best performance
45 - If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
46 required. Most modern Linux distributions, as well as Solaris 10 and later,
47 include JDK or OpenJDK. On OS X 10.5 and 10.6, it will be necessary to
48 install the Java Developer Package, which can be downloaded from
49 <http://developer.apple.com/downloads> (Apple ID required.) For other
50 systems, you can obtain the Oracle Java Development Kit from
51 <http://www.java.com>.
56 - Microsoft Visual C++ 2005 or later
58 If you don't already have Visual C++, then the easiest way to get it is by
60 [Windows SDK](http://msdn.microsoft.com/en-us/windows/bb980924.aspx).
61 The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
62 everything necessary to build libjpeg-turbo.
64 * You can also use Microsoft Visual Studio Express/Community Edition, which
65 is a free download. (NOTE: versions prior to 2012 can only be used to
67 * If you intend to build libjpeg-turbo from the command line, then add the
68 appropriate compiler and SDK directories to the `INCLUDE`, `LIB`, and
69 `PATH` environment variables. This is generally accomplished by
70 executing `vcvars32.bat` or `vcvars64.bat` and `SetEnv.cmd`.
71 `vcvars32.bat` and `vcvars64.bat` are part of Visual C++ and are located in
72 the same directory as the compiler. `SetEnv.cmd` is part of the Windows
73 SDK. You can pass optional arguments to `SetEnv.cmd` to specify a 32-bit
74 or 64-bit build environment.
80 [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/)
81 recommended if building on a Windows machine. Both distributions install a
82 Start Menu link that can be used to launch a command prompt with the
83 appropriate compiler paths automatically set.
85 - If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
86 can be downloaded from <http://www.java.com>.
92 Binary objects, libraries, and executables are generated in the directory from
93 which CMake is executed (the "binary directory"), and this directory need not
94 necessarily be the same as the libjpeg-turbo source directory. You can create
95 multiple independent binary directories, in which different versions of
96 libjpeg-turbo can be built from the same source tree using different compilers
97 or settings. In the sections below, *{build_directory}* refers to the binary
98 directory, whereas *{source_directory}* refers to the libjpeg-turbo source
99 directory. For in-tree builds, these directories are the same.
105 NOTE: The build procedures below assume that CMake is invoked from the command
106 line, but all of these procedures can be adapted to the CMake GUI as
112 The following procedure will build libjpeg-turbo on Unix and Unix-like systems.
113 (On Solaris, this generates a 32-bit build. See "Build Recipes" below for
114 64-bit build instructions.)
117 cmake -G"Unix Makefiles" [additional CMake flags] {source_directory}
120 This will generate the following files under *{build_directory}*:
123 Static link library for the libjpeg API
125 **libjpeg.so.{version}** (Linux, Unix)<br>
126 **libjpeg.{version}.dylib** (Mac)<br>
127 **cygjpeg-{version}.dll** (Cygwin)<br>
128 Shared library for the libjpeg API
130 By default, *{version}* is 62.2.0, 7.2.0, or 8.1.2, depending on whether
131 libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin,
132 *{version}* is 62, 7, or 8.
134 **libjpeg.so** (Linux, Unix)<br>
135 **libjpeg.dylib** (Mac)<br>
136 Development symlink for the libjpeg API
138 **libjpeg.dll.a** (Cygwin)<br>
139 Import library for the libjpeg API
141 **libturbojpeg.a**<br>
142 Static link library for the TurboJPEG API
144 **libturbojpeg.so.0.2.0** (Linux, Unix)<br>
145 **libturbojpeg.0.2.0.dylib** (Mac)<br>
146 **cygturbojpeg-0.dll** (Cygwin)<br>
147 Shared library for the TurboJPEG API
149 **libturbojpeg.so** (Linux, Unix)<br>
150 **libturbojpeg.dylib** (Mac)<br>
151 Development symlink for the TurboJPEG API
153 **libturbojpeg.dll.a** (Cygwin)<br>
154 Import library for the TurboJPEG API
157 ### Visual C++ (Command Line)
160 cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory}
163 This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
164 on which version of **cl.exe** is in the `PATH`.
166 The following files will be generated under *{build_directory}*:
168 **jpeg-static.lib**<br>
169 Static link library for the libjpeg API
171 **jpeg{version}.dll**<br>
172 DLL for the libjpeg API
175 Import library for the libjpeg API
177 **turbojpeg-static.lib**<br>
178 Static link library for the TurboJPEG API
180 **turbojpeg.dll**<br>
181 DLL for the TurboJPEG API
183 **turbojpeg.lib**<br>
184 Import library for the TurboJPEG API
186 *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
187 v8 emulation is enabled.
192 Choose the appropriate CMake generator option for your version of Visual Studio
193 (run `cmake` with no arguments for a list of available generators.) For
197 cmake -G"Visual Studio 10" [additional CMake flags] {source_directory}
199 NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10 Win64")
200 to build a 64-bit version of libjpeg-turbo. A separate build directory must be
201 used for 32-bit and 64-bit builds.
203 You can then open **ALL_BUILD.vcproj** in Visual Studio and build one of the
204 configurations in that project ("Debug", "Release", etc.) to generate a full
205 build of libjpeg-turbo.
207 This will generate the following files under *{build_directory}*:
209 **{configuration}/jpeg-static.lib**<br>
210 Static link library for the libjpeg API
212 **{configuration}/jpeg{version}.dll**<br>
213 DLL for the libjpeg API
215 **{configuration}/jpeg.lib**<br>
216 Import library for the libjpeg API
218 **{configuration}/turbojpeg-static.lib**<br>
219 Static link library for the TurboJPEG API
221 **{configuration}/turbojpeg.dll**<br>
222 DLL for the TurboJPEG API
224 **{configuration}/turbojpeg.lib**<br>
225 Import library for the TurboJPEG API
227 *{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending
228 on the configuration you built in the IDE, and *{version}* is 62, 7, or 8,
229 depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
234 NOTE: This assumes that you are building on a Windows machine using the MSYS
235 environment. If you are cross-compiling on a Un*x platform (including Mac and
236 Cygwin), then see "Build Recipes" below.
239 cmake -G"MSYS Makefiles" [additional CMake flags] {source_directory}
242 This will generate the following files under *{build_directory}*:
245 Static link library for the libjpeg API
247 **libjpeg-{version}.dll**<br>
248 DLL for the libjpeg API
250 **libjpeg.dll.a**<br>
251 Import library for the libjpeg API
253 **libturbojpeg.a**<br>
254 Static link library for the TurboJPEG API
256 **libturbojpeg.dll**<br>
257 DLL for the TurboJPEG API
259 **libturbojpeg.dll.a**<br>
260 Import library for the TurboJPEG API
262 *{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
263 v8 emulation is enabled.
268 Add `-DCMAKE_BUILD_TYPE=Debug` to the CMake command line. Or, if building
269 with NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default
273 ### libjpeg v7 or v8 API/ABI Emulation
275 Add `-DWITH_JPEG7=1` to the CMake command line to build a version of
276 libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add `-DWITH_JPEG8=1`
277 to the CMake command line to build a version of libjpeg-turbo that is
278 API/ABI-compatible with libjpeg v8. See [README.md](README.md) for more
279 information about libjpeg v7 and v8 emulation.
282 ### In-Memory Source/Destination Managers
284 When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
285 the CMake command line to build a version of libjpeg-turbo that lacks the
286 `jpeg_mem_src()` and `jpeg_mem_dest()` functions. These functions were not
287 part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
288 conformance with those APIs. See [README.md](README.md) for more information.
291 ### Arithmetic Coding Support
293 Since the patent on arithmetic coding has expired, this functionality has been
294 included in this release of libjpeg-turbo. libjpeg-turbo's implementation is
295 based on the implementation in libjpeg v8, but it works when emulating libjpeg
296 v7 or v6b as well. The default is to enable both arithmetic encoding and
297 decoding, but those who have philosophical objections to arithmetic coding can
298 add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the CMake command line to
299 disable encoding or decoding (respectively.)
302 ### TurboJPEG Java Wrapper
304 Add `-DWITH_JAVA=1` to the CMake command line to incorporate an optional Java
305 Native Interface (JNI) wrapper into the TurboJPEG shared library and build the
306 Java front-end classes to support it. This allows the TurboJPEG shared library
307 to be used directly from Java applications. See [java/README](java/README) for
310 If Java is not in your `PATH`, or if you wish to use an alternate JDK to
311 build/test libjpeg-turbo, then (prior to running CMake) set the `JAVA_HOME`
312 environment variable to the location of the JDK that you wish to use. The
313 `Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and `Java_JAR_EXECUTABLE`
314 CMake variables can also be used to specify alternate commands or locations for
315 javac, jar, and java (respectively.) You can also set the
316 `CMAKE_JAVA_COMPILE_FLAGS` CMake variable or the `JAVAFLAGS` environment
317 variable to specify arguments that should be passed to the Java compiler when
318 building the TurboJPEG classes, and the `JAVAARGS` CMake variable to specify
319 arguments that should be passed to the JRE when running the TurboJPEG Java unit
327 ### 32-bit Build on 64-bit Linux/Unix/Mac
329 Use export/setenv to set the following environment variables before running
336 ### 64-bit Build on Solaris
338 Use export/setenv to set the following environment variables before running
347 On Un*x systems, prior to running CMake, you can set the `CC` environment
348 variable to the command used to invoke the C compiler.
351 ### 32-bit MinGW Build on Un*x (including Mac and Cygwin)
353 Create a file called **toolchain.cmake** under *{build_directory}*, with the
356 set(CMAKE_SYSTEM_NAME Windows)
357 set(CMAKE_SYSTEM_PROCESSOR X86)
358 set(CMAKE_C_COMPILER {mingw_binary_path}/i686-w64-mingw32-gcc)
359 set(CMAKE_RC_COMPILER {mingw_binary_path}/i686-w64-mingw32-windres)
361 *{mingw\_binary\_path}* is the directory under which the MinGW binaries are
362 located (usually **/usr/bin**.) Next, execute the following commands:
365 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
366 [additional CMake flags] {source_directory}
370 ### 64-bit MinGW Build on Un*x (including Mac and Cygwin)
372 Create a file called **toolchain.cmake** under *{build_directory}*, with the
375 set(CMAKE_SYSTEM_NAME Windows)
376 set(CMAKE_SYSTEM_PROCESSOR AMD64)
377 set(CMAKE_C_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-gcc)
378 set(CMAKE_RC_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-windres)
380 *{mingw\_binary\_path}* is the directory under which the MinGW binaries are
381 located (usually **/usr/bin**.) Next, execute the following commands:
384 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
385 [additional CMake flags] {source_directory}
389 Building libjpeg-turbo for iOS
390 ------------------------------
392 iOS platforms, such as the iPhone and iPad, use ARM processors, and all
393 currently supported models include NEON instructions. Thus, they can take
394 advantage of libjpeg-turbo's SIMD extensions to significantly accelerate JPEG
395 compression/decompression. This section describes how to build libjpeg-turbo
399 ### Additional build requirements
401 - For configurations that require [gas-preprocessor.pl]
402 (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl),
403 it should be installed in your `PATH`.
408 **gas-preprocessor.pl required**
410 The following scripts demonstrate how to build libjpeg-turbo to run on the
411 iPhone 3GS-4S/iPad 1st-3rd Generation and newer:
413 #### Xcode 4.2 and earlier (LLVM-GCC)
415 IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform
416 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
417 export CFLAGS="-mfloat-abi=softfp -march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -miphoneos-version-min=3.0"
421 cat <<EOF >toolchain.cmake
422 set(CMAKE_SYSTEM_NAME Darwin)
423 set(CMAKE_SYSTEM_PROCESSOR arm)
424 set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
427 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
428 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
429 [additional CMake flags] {source_directory}
432 #### Xcode 4.3-4.6 (LLVM-GCC)
434 Same as above, but replace the first line with:
436 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
438 #### Xcode 5 and later (Clang)
440 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
441 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
442 export CFLAGS="-mfloat-abi=softfp -arch armv7 -miphoneos-version-min=3.0"
443 export ASMFLAGS="-no-integrated-as"
447 cat <<EOF >toolchain.cmake
448 set(CMAKE_SYSTEM_NAME Darwin)
449 set(CMAKE_SYSTEM_PROCESSOR arm)
450 set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
453 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
454 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
455 [additional CMake flags] {source_directory}
461 **gas-preprocessor.pl required**
463 The following scripts demonstrate how to build libjpeg-turbo to run on the
464 iPhone 5/iPad 4th Generation and newer:
466 #### Xcode 4.5-4.6 (LLVM-GCC)
468 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
469 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
470 export CFLAGS="-Wall -mfloat-abi=softfp -march=armv7s -mcpu=swift -mtune=swift -mfpu=neon -miphoneos-version-min=6.0"
474 cat <<EOF >toolchain.cmake
475 set(CMAKE_SYSTEM_NAME Darwin)
476 set(CMAKE_SYSTEM_PROCESSOR arm)
477 set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
480 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
481 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
482 [additional CMake flags] {source_directory}
485 #### Xcode 5 and later (Clang)
487 Same as the ARMv7 build procedure for Xcode 5 and later, except replace the
488 compiler flags as follows:
490 export CFLAGS="-Wall -mfloat-abi=softfp -arch armv7s -miphoneos-version-min=6.0"
495 **gas-preprocessor.pl required if using Xcode < 6**
497 The following script demonstrates how to build libjpeg-turbo to run on the
498 iPhone 5S/iPad Mini 2/iPad Air and newer.
500 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
501 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
502 export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=7.0 -funwind-tables"
506 cat <<EOF >toolchain.cmake
507 set(CMAKE_SYSTEM_NAME Darwin)
508 set(CMAKE_SYSTEM_PROCESSOR aarch64)
509 set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
512 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
513 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
514 [additional CMake flags] {source_directory}
517 Once built, lipo can be used to combine the ARMv7, v7s, and/or v8 variants into
521 Building libjpeg-turbo for Android
522 ----------------------------------
524 Building libjpeg-turbo for Android platforms requires the
525 [Android NDK](https://developer.android.com/tools/sdk/ndk).
530 The following is a general recipe script that can be modified for your specific
533 # Set these variables to suit your needs
534 NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
535 BUILD_PLATFORM={the platform name for the NDK package you installed--
536 for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
537 TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
538 toolchain directory under ${NDK_PATH}/toolchains/.}
539 ANDROID_VERSION={The minimum version of Android to support-- for example,
542 # It should not be necessary to modify the rest
543 HOST=arm-linux-androideabi
544 SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
545 export CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
546 -D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
547 -isystem ${NDK_PATH}/sysroot/usr/include \
548 -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
550 TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
554 cat <<EOF >toolchain.cmake
555 set(CMAKE_SYSTEM_NAME Linux)
556 set(CMAKE_SYSTEM_PROCESSOR arm)
557 set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
558 set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
561 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
562 -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
563 [additional CMake flags] {source_directory}
569 The following is a general recipe script that can be modified for your specific
572 # Set these variables to suit your needs
573 NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
574 BUILD_PLATFORM={the platform name for the NDK package you installed--
575 for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
576 TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
577 toolchain directory under ${NDK_PATH}/toolchains/.}
578 ANDROID_VERSION={The minimum version of Android to support. "21" or later
579 is required for a 64-bit build.}
581 # It should not be necessary to modify the rest
582 HOST=aarch64-linux-android
583 SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64
584 export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
585 -isystem ${NDK_PATH}/sysroot/usr/include \
586 -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
588 TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
592 cat <<EOF >toolchain.cmake
593 set(CMAKE_SYSTEM_NAME Linux)
594 set(CMAKE_SYSTEM_PROCESSOR aarch64)
595 set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
596 set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
599 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
600 -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
601 [additional CMake flags] {source_directory}
607 The following is a general recipe script that can be modified for your specific
610 # Set these variables to suit your needs
611 NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
612 BUILD_PLATFORM={the platform name for the NDK package you installed--
613 for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
614 TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
615 toolchain directory under ${NDK_PATH}/toolchains/.}
616 ANDROID_VERSION={The minimum version of Android to support-- for example,
619 # It should not be necessary to modify the rest
620 HOST=i686-linux-android
621 SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-x86
622 export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
623 -isystem ${NDK_PATH}/sysroot/usr/include \
624 -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
626 TOOLCHAIN=${NDK_PATH}/toolchains/x86-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
630 cat <<EOF >toolchain.cmake
631 set(CMAKE_SYSTEM_NAME Linux)
632 set(CMAKE_SYSTEM_PROCESSOR i386)
633 set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
634 set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
637 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
638 -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
639 [additional CMake flags] {source_directory}
645 The following is a general recipe script that can be modified for your specific
648 # Set these variables to suit your needs
649 NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
650 BUILD_PLATFORM={the platform name for the NDK package you installed--
651 for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
652 TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
653 toolchain directory under ${NDK_PATH}/toolchains/.}
654 ANDROID_VERSION={The minimum version of Android to support. "21" or later
655 is required for a 64-bit build.}
657 # It should not be necessary to modify the rest
658 HOST=x86_64-linux-android
659 SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-x86_64
660 export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
661 -isystem ${NDK_PATH}/sysroot/usr/include \
662 -isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
664 TOOLCHAIN=${NDK_PATH}/toolchains/x86_64-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
668 cat <<EOF >toolchain.cmake
669 set(CMAKE_SYSTEM_NAME Linux)
670 set(CMAKE_SYSTEM_PROCESSOR x86_64)
671 set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
672 set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
675 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
676 -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
677 [additional CMake flags] {source_directory}
681 If building for Android 4.0.x (API level < 16) or earlier, remove
682 `-DCMAKE_POSITION_INDEPENDENT_CODE=1` from the CMake arguments and `-pie` from
686 Advanced CMake Options
687 ----------------------
689 To list and configure other CMake options not specifically mentioned in this
692 ccmake {source_directory}
696 cmake-gui {source_directory}
698 from the build directory after initially configuring the build. CCMake is a
699 text-based interactive version of CMake, and CMake-GUI is a GUI version. Both
700 will display all variables that are relevant to the libjpeg-turbo build, their
701 current values, and a help string describing what they do.
704 Installing libjpeg-turbo
705 ========================
707 You can use the build system to install libjpeg-turbo (as opposed to creating
708 an installer package.) To do this, run `make install` or `nmake install`
709 (or build the "install" target in the Visual Studio IDE.) Running
710 `make uninstall` or `nmake uninstall` (or building the "uninstall" target in
711 the Visual Studio IDE) will uninstall libjpeg-turbo.
713 The `CMAKE_INSTALL_PREFIX` CMake variable can be modified in order to install
714 libjpeg-turbo into a directory of your choosing. If you don't specify
715 `CMAKE_INSTALL_PREFIX`, then the default is:
717 **c:\libjpeg-turbo**<br>
718 Visual Studio 32-bit build
720 **c:\libjpeg-turbo64**<br>
721 Visual Studio 64-bit build
723 **c:\libjpeg-turbo-gcc**<br>
726 **c:\libjpeg-turbo-gcc64**<br>
729 **/opt/libjpeg-turbo**<br>
732 The default value of `CMAKE_INSTALL_PREFIX` causes the libjpeg-turbo files to
733 be installed with a directory structure resembling that of the official
734 libjpeg-turbo binary packages. Changing the value of `CMAKE_INSTALL_PREFIX`
735 (for instance, to **/usr/local**) causes the libjpeg-turbo files to be
736 installed with a directory structure that conforms to GNU standards.
738 The `CMAKE_INSTALL_BINDIR`, `CMAKE_INSTALL_DATAROOTDIR`,
739 `CMAKE_INSTALL_DOCDIR`, `CMAKE_INSTALL_INCLUDEDIR`, `CMAKE_INSTALL_JAVADIR`,
740 `CMAKE_INSTALL_LIBDIR`, and `CMAKE_INSTALL_MANDIR` CMake variables allow a
741 finer degree of control over where specific files in the libjpeg-turbo
742 distribution should be installed. These directory variables can either be
743 specified as absolute paths or as paths relative to `CMAKE_INSTALL_PREFIX` (for
744 instance, setting `CMAKE_INSTALL_DOCDIR` to **doc** would cause the
745 documentation to be installed in **${CMAKE\_INSTALL\_PREFIX}/doc**.) If a
746 directory variable contains the name of another directory variable in angle
747 brackets, then its final value will depend on the final value of that other
748 variable. For instance, the default value of `CMAKE_INSTALL_MANDIR` is
749 **\<CMAKE\_INSTALL\_DATAROOTDIR\>/man**.
751 NOTE: If setting one of these directory variables to a relative path using the
752 CMake command line, you must specify that the variable is of type `PATH`.
755 cmake -G"{generator type}" -DCMAKE_INSTALL_LIBDIR:PATH=lib {source_directory}
757 Otherwise, CMake will assume that the path is relative to the build directory
758 rather than the install directory.
761 Creating Distribution Packages
762 ==============================
764 The following commands can be used to create various types of distribution
773 Create Red Hat-style binary RPM package. Requires RPM v4 or later.
777 This runs `make dist` to create a pristine source tarball, then creates a
778 Red Hat-style source RPM package from the tarball. Requires RPM v4 or later.
782 Create Debian-style binary package. Requires dpkg.
790 Create Mac package/disk image. This requires pkgbuild and productbuild, which
791 are installed by default on OS X 10.7 and later and which can be obtained by
792 installing Xcode 3.2.6 (with the "Unix Development" option) on OS X 10.6.
793 Packages built in this manner can be installed on OS X 10.5 and later, but they
794 must be built on OS X 10.6 or later.
798 This creates a Mac package/disk image that contains universal x86-64/i386/ARM
799 binaries. The following CMake variables control which architectures are
800 included in the universal binaries. Setting any of these variables to an empty
801 string excludes that architecture from the package.
803 * `OSX_32BIT_BUILD`: Directory containing an i386 (32-bit) Mac build of
804 libjpeg-turbo (default: *{source_directory}*/osxx86)
805 * `IOS_ARMV7_BUILD`: Directory containing an ARMv7 (32-bit) iOS build of
806 libjpeg-turbo (default: *{source_directory}*/iosarmv7)
807 * `IOS_ARMV7S_BUILD`: Directory containing an ARMv7s (32-bit) iOS build of
808 libjpeg-turbo (default: *{source_directory}*/iosarmv7s)
809 * `IOS_ARMV8_BUILD`: Directory containing an ARMv8 (64-bit) iOS build of
810 libjpeg-turbo (default: *{source_directory}*/iosarmv8)
812 You should first use CMake to configure i386, ARMv7, ARMv7s, and/or ARMv8
813 sub-builds of libjpeg-turbo (see "Build Recipes" and "Building libjpeg-turbo
814 for iOS" above) in build directories that match those specified in the
815 aforementioned CMake variables. Next, configure the primary build of
816 libjpeg-turbo as an out-of-tree build, and build it. Once the primary build
817 has been built, run `make udmg` from the build directory. The packaging system
818 will build the sub-builds, use lipo to combine them into a single set of
819 universal binaries, then package the universal binaries in the same manner as
828 Build a Cygwin binary package.
844 If using the Visual Studio IDE, build the "installer" target.
846 The installer package (libjpeg-turbo-*{version}*[-gcc|-vc][64].exe) will be
847 located under *{build_directory}*. If building using the Visual Studio IDE,
848 then the installer package will be located in a subdirectory with the same name
849 as the configuration you built (such as *{build_directory}*\Debug\ or
850 *{build_directory}*\Release\).
852 Building a Windows installer requires the
853 [Nullsoft Install System](http://nsis.sourceforge.net/). makensis.exe should
860 The most common way to test libjpeg-turbo is by invoking `make test` (Un*x) or
861 `nmake test` (Windows command line) or by building the "RUN_TESTS" target
862 (Visual Studio IDE), once the build has completed. This runs a series of tests
863 to ensure that mathematical compatibility has been maintained between
864 libjpeg-turbo and libjpeg v6b. This also invokes the TurboJPEG unit tests,
865 which ensure that the colorspace extensions, YUV encoding, decompression
866 scaling, and other features of the TurboJPEG C and Java APIs are working
867 properly (and, by extension, that the equivalent features of the underlying
868 libjpeg API are also working.)
870 Invoking `make testclean` (Un*x) or `nmake testclean` (Windows command line) or
871 building the "testclean" target (Visual Studio IDE) will clean up the output
872 images generated by the tests.
874 On Un*x platforms, more extensive tests of the TurboJPEG C and Java wrappers
875 can be run by invoking `make tjtest`. These extended TurboJPEG tests
876 essentially iterate through all of the available features of the TurboJPEG APIs
877 that are not covered by the TurboJPEG unit tests (including the lossless
878 transform options) and compare the images generated by each feature to images
879 generated using the equivalent feature in the libjpeg API. The extended
880 TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
881 not in the underlying libjpeg API library.