1Building libjpeg-turbo 2====================== 3 4 5Build Requirements 6------------------ 7 8 9### All Systems 10 11- [CMake](http://www.cmake.org) v2.8.12 or later 12 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.) 19 * If using YASM, 1.2.0 or later is required. 20 * If building on macOS, NASM or YASM can be obtained from 21 [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/). 22 - NOTE: Currently, if it is desirable to hide the SIMD function symbols in 23 Mac executables or shared libraries that statically link with 24 libjpeg-turbo, then NASM 2.14 or later or YASM must be used when 25 building libjpeg-turbo. 26 * If building on Windows, **nasm.exe**/**yasm.exe** should be in your `PATH`. 27 * NASM and YASM are located in the CRB (Code Ready Builder) repository on 28 Red Hat Enterprise Linux 8 and in the PowerTools repository on CentOS 8, 29 which is not enabled by default. 30 31 The binary RPMs released by the NASM project do not work on older Linux 32 systems, such as Red Hat Enterprise Linux 5. On such systems, you can easily 33 build and install NASM from a source RPM by downloading one of the SRPMs from 34 35 <http://www.nasm.us/pub/nasm/releasebuilds> 36 37 and executing the following as root: 38 39 ARCH=`uname -m` 40 rpmbuild --rebuild nasm-{version}.src.rpm 41 rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm 42 43 NOTE: the NASM build will fail if texinfo is not installed. 44 45 46### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin) 47 48- GCC v4.1 (or later) or Clang recommended for best performance 49 50- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is 51 required. Most modern Linux distributions, as well as Solaris 10 and later, 52 include JDK or OpenJDK. On OS X 10.5 and 10.6, it will be necessary to 53 install the Java Developer Package, which can be downloaded from 54 <http://developer.apple.com/downloads> (Apple ID required.) For other 55 systems, you can obtain the Oracle Java Development Kit from 56 <http://www.oracle.com/technetwork/java/javase/downloads>. 57 58 * If using JDK 11 or later, CMake 3.10.x or later must also be used. 59 60### Windows 61 62- Microsoft Visual C++ 2005 or later 63 64 If you don't already have Visual C++, then the easiest way to get it is by 65 installing the 66 [Windows SDK](http://msdn.microsoft.com/en-us/windows/bb980924.aspx). 67 The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and 68 everything necessary to build libjpeg-turbo. 69 70 * You can also use Microsoft Visual Studio Express/Community Edition, which 71 is a free download. (NOTE: versions prior to 2012 can only be used to 72 build 32-bit code.) 73 * If you intend to build libjpeg-turbo from the command line, then add the 74 appropriate compiler and SDK directories to the `INCLUDE`, `LIB`, and 75 `PATH` environment variables. This is generally accomplished by 76 executing `vcvars32.bat` or `vcvars64.bat` and `SetEnv.cmd`. 77 `vcvars32.bat` and `vcvars64.bat` are part of Visual C++ and are located in 78 the same directory as the compiler. `SetEnv.cmd` is part of the Windows 79 SDK. You can pass optional arguments to `SetEnv.cmd` to specify a 32-bit 80 or 64-bit build environment. 81 82 ... OR ... 83 84- MinGW 85 86 [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/) 87 recommended if building on a Windows machine. Both distributions install a 88 Start Menu link that can be used to launch a command prompt with the 89 appropriate compiler paths automatically set. 90 91- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This 92 can be downloaded from 93 <http://www.oracle.com/technetwork/java/javase/downloads>. 94 95 * If using JDK 11 or later, CMake 3.10.x or later must also be used. 96 97 98Out-of-Tree Builds 99------------------ 100 101Binary objects, libraries, and executables are generated in the directory from 102which CMake is executed (the "binary directory"), and this directory need not 103necessarily be the same as the libjpeg-turbo source directory. You can create 104multiple independent binary directories, in which different versions of 105libjpeg-turbo can be built from the same source tree using different compilers 106or settings. In the sections below, *{build_directory}* refers to the binary 107directory, whereas *{source_directory}* refers to the libjpeg-turbo source 108directory. For in-tree builds, these directories are the same. 109 110 111Build Procedure 112--------------- 113 114NOTE: The build procedures below assume that CMake is invoked from the command 115line, but all of these procedures can be adapted to the CMake GUI as 116well. 117 118 119### Un*x 120 121The following procedure will build libjpeg-turbo on Unix and Unix-like systems. 122(On Solaris, this generates a 32-bit build. See "Build Recipes" below for 12364-bit build instructions.) 124 125 cd {build_directory} 126 cmake -G"Unix Makefiles" [additional CMake flags] {source_directory} 127 make 128 129This will generate the following files under *{build_directory}*: 130 131**libjpeg.a**<br> 132Static link library for the libjpeg API 133 134**libjpeg.so.{version}** (Linux, Unix)<br> 135**libjpeg.{version}.dylib** (Mac)<br> 136**cygjpeg-{version}.dll** (Cygwin)<br> 137Shared library for the libjpeg API 138 139By default, *{version}* is 62.2.0, 7.2.0, or 8.1.2, depending on whether 140libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin, 141*{version}* is 62, 7, or 8. 142 143**libjpeg.so** (Linux, Unix)<br> 144**libjpeg.dylib** (Mac)<br> 145Development symlink for the libjpeg API 146 147**libjpeg.dll.a** (Cygwin)<br> 148Import library for the libjpeg API 149 150**libturbojpeg.a**<br> 151Static link library for the TurboJPEG API 152 153**libturbojpeg.so.0.2.0** (Linux, Unix)<br> 154**libturbojpeg.0.2.0.dylib** (Mac)<br> 155**cygturbojpeg-0.dll** (Cygwin)<br> 156Shared library for the TurboJPEG API 157 158**libturbojpeg.so** (Linux, Unix)<br> 159**libturbojpeg.dylib** (Mac)<br> 160Development symlink for the TurboJPEG API 161 162**libturbojpeg.dll.a** (Cygwin)<br> 163Import library for the TurboJPEG API 164 165 166### Visual C++ (Command Line) 167 168 cd {build_directory} 169 cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory} 170 nmake 171 172This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending 173on which version of **cl.exe** is in the `PATH`. 174 175The following files will be generated under *{build_directory}*: 176 177**jpeg-static.lib**<br> 178Static link library for the libjpeg API 179 180**jpeg{version}.dll**<br> 181DLL for the libjpeg API 182 183**jpeg.lib**<br> 184Import library for the libjpeg API 185 186**turbojpeg-static.lib**<br> 187Static link library for the TurboJPEG API 188 189**turbojpeg.dll**<br> 190DLL for the TurboJPEG API 191 192**turbojpeg.lib**<br> 193Import library for the TurboJPEG API 194 195*{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or 196v8 emulation is enabled. 197 198 199### Visual C++ (IDE) 200 201Choose the appropriate CMake generator option for your version of Visual Studio 202(run `cmake` with no arguments for a list of available generators.) For 203instance: 204 205 cd {build_directory} 206 cmake -G"Visual Studio 10" [additional CMake flags] {source_directory} 207 208NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10 Win64") 209to build a 64-bit version of libjpeg-turbo. A separate build directory must be 210used for 32-bit and 64-bit builds. 211 212You can then open **ALL_BUILD.vcproj** in Visual Studio and build one of the 213configurations in that project ("Debug", "Release", etc.) to generate a full 214build of libjpeg-turbo. 215 216This will generate the following files under *{build_directory}*: 217 218**{configuration}/jpeg-static.lib**<br> 219Static link library for the libjpeg API 220 221**{configuration}/jpeg{version}.dll**<br> 222DLL for the libjpeg API 223 224**{configuration}/jpeg.lib**<br> 225Import library for the libjpeg API 226 227**{configuration}/turbojpeg-static.lib**<br> 228Static link library for the TurboJPEG API 229 230**{configuration}/turbojpeg.dll**<br> 231DLL for the TurboJPEG API 232 233**{configuration}/turbojpeg.lib**<br> 234Import library for the TurboJPEG API 235 236*{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending 237on the configuration you built in the IDE, and *{version}* is 62, 7, or 8, 238depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled. 239 240 241### MinGW 242 243NOTE: This assumes that you are building on a Windows machine using the MSYS 244environment. If you are cross-compiling on a Un*x platform (including Mac and 245Cygwin), then see "Build Recipes" below. 246 247 cd {build_directory} 248 cmake -G"MSYS Makefiles" [additional CMake flags] {source_directory} 249 make 250 251This will generate the following files under *{build_directory}*: 252 253**libjpeg.a**<br> 254Static link library for the libjpeg API 255 256**libjpeg-{version}.dll**<br> 257DLL for the libjpeg API 258 259**libjpeg.dll.a**<br> 260Import library for the libjpeg API 261 262**libturbojpeg.a**<br> 263Static link library for the TurboJPEG API 264 265**libturbojpeg.dll**<br> 266DLL for the TurboJPEG API 267 268**libturbojpeg.dll.a**<br> 269Import library for the TurboJPEG API 270 271*{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or 272v8 emulation is enabled. 273 274 275### Debug Build 276 277Add `-DCMAKE_BUILD_TYPE=Debug` to the CMake command line. Or, if building 278with NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default 279with NMake.) 280 281 282### libjpeg v7 or v8 API/ABI Emulation 283 284Add `-DWITH_JPEG7=1` to the CMake command line to build a version of 285libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add `-DWITH_JPEG8=1` 286to the CMake command line to build a version of libjpeg-turbo that is 287API/ABI-compatible with libjpeg v8. See [README.md](README.md) for more 288information about libjpeg v7 and v8 emulation. 289 290 291### In-Memory Source/Destination Managers 292 293When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to 294the CMake command line to build a version of libjpeg-turbo that lacks the 295`jpeg_mem_src()` and `jpeg_mem_dest()` functions. These functions were not 296part of the original libjpeg v6b and v7 APIs, so removing them ensures strict 297conformance with those APIs. See [README.md](README.md) for more information. 298 299 300### Arithmetic Coding Support 301 302Since the patent on arithmetic coding has expired, this functionality has been 303included in this release of libjpeg-turbo. libjpeg-turbo's implementation is 304based on the implementation in libjpeg v8, but it works when emulating libjpeg 305v7 or v6b as well. The default is to enable both arithmetic encoding and 306decoding, but those who have philosophical objections to arithmetic coding can 307add `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the CMake command line to 308disable encoding or decoding (respectively.) 309 310 311### TurboJPEG Java Wrapper 312 313Add `-DWITH_JAVA=1` to the CMake command line to incorporate an optional Java 314Native Interface (JNI) wrapper into the TurboJPEG shared library and build the 315Java front-end classes to support it. This allows the TurboJPEG shared library 316to be used directly from Java applications. See [java/README](java/README) for 317more details. 318 319If Java is not in your `PATH`, or if you wish to use an alternate JDK to 320build/test libjpeg-turbo, then (prior to running CMake) set the `JAVA_HOME` 321environment variable to the location of the JDK that you wish to use. The 322`Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and `Java_JAR_EXECUTABLE` 323CMake variables can also be used to specify alternate commands or locations for 324javac, jar, and java (respectively.) You can also set the 325`CMAKE_JAVA_COMPILE_FLAGS` CMake variable or the `JAVAFLAGS` environment 326variable to specify arguments that should be passed to the Java compiler when 327building the TurboJPEG classes, and the `JAVAARGS` CMake variable to specify 328arguments that should be passed to the JRE when running the TurboJPEG Java unit 329tests. 330 331 332Build Recipes 333------------- 334 335 336### 32-bit Build on 64-bit Linux/Unix/Mac 337 338Use export/setenv to set the following environment variables before running 339CMake: 340 341 CFLAGS=-m32 342 LDFLAGS=-m32 343 344 345### 64-bit Build on Solaris 346 347Use export/setenv to set the following environment variables before running 348CMake: 349 350 CFLAGS=-m64 351 LDFLAGS=-m64 352 353 354### Other Compilers 355 356On Un*x systems, prior to running CMake, you can set the `CC` environment 357variable to the command used to invoke the C compiler. 358 359 360### 32-bit MinGW Build on Un*x (including Mac and Cygwin) 361 362Create a file called **toolchain.cmake** under *{build_directory}*, with the 363following contents: 364 365 set(CMAKE_SYSTEM_NAME Windows) 366 set(CMAKE_SYSTEM_PROCESSOR X86) 367 set(CMAKE_C_COMPILER {mingw_binary_path}/i686-w64-mingw32-gcc) 368 set(CMAKE_RC_COMPILER {mingw_binary_path}/i686-w64-mingw32-windres) 369 370*{mingw\_binary\_path}* is the directory under which the MinGW binaries are 371located (usually **/usr/bin**.) Next, execute the following commands: 372 373 cd {build_directory} 374 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ 375 [additional CMake flags] {source_directory} 376 make 377 378 379### 64-bit MinGW Build on Un*x (including Mac and Cygwin) 380 381Create a file called **toolchain.cmake** under *{build_directory}*, with the 382following contents: 383 384 set(CMAKE_SYSTEM_NAME Windows) 385 set(CMAKE_SYSTEM_PROCESSOR AMD64) 386 set(CMAKE_C_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-gcc) 387 set(CMAKE_RC_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-windres) 388 389*{mingw\_binary\_path}* is the directory under which the MinGW binaries are 390located (usually **/usr/bin**.) Next, execute the following commands: 391 392 cd {build_directory} 393 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ 394 [additional CMake flags] {source_directory} 395 make 396 397 398Building libjpeg-turbo for iOS 399------------------------------ 400 401iOS platforms, such as the iPhone and iPad, use ARM processors, and all 402currently supported models include NEON instructions. Thus, they can take 403advantage of libjpeg-turbo's SIMD extensions to significantly accelerate JPEG 404compression/decompression. This section describes how to build libjpeg-turbo 405for these platforms. 406 407 408### Additional build requirements 409 410- For configurations that require [gas-preprocessor.pl] 411 (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl), 412 it should be installed in your `PATH`. 413 414 415### ARMv7 (32-bit) 416 417**gas-preprocessor.pl required** 418 419The following scripts demonstrate how to build libjpeg-turbo to run on the 420iPhone 3GS-4S/iPad 1st-3rd Generation and newer: 421 422#### Xcode 4.2 and earlier (LLVM-GCC) 423 424 IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform 425 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) 426 export CFLAGS="-mfloat-abi=softfp -march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -miphoneos-version-min=3.0" 427 428 cd {build_directory} 429 430 cat <<EOF >toolchain.cmake 431 set(CMAKE_SYSTEM_NAME Darwin) 432 set(CMAKE_SYSTEM_PROCESSOR arm) 433 set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2) 434 EOF 435 436 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ 437 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \ 438 [additional CMake flags] {source_directory} 439 make 440 441#### Xcode 4.3-4.6 (LLVM-GCC) 442 443Same as above, but replace the first line with: 444 445 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform 446 447#### Xcode 5 and later (Clang) 448 449 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform 450 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) 451 export CFLAGS="-mfloat-abi=softfp -arch armv7 -miphoneos-version-min=3.0" 452 export ASMFLAGS="-no-integrated-as" 453 454 cd {build_directory} 455 456 cat <<EOF >toolchain.cmake 457 set(CMAKE_SYSTEM_NAME Darwin) 458 set(CMAKE_SYSTEM_PROCESSOR arm) 459 set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang) 460 EOF 461 462 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ 463 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \ 464 [additional CMake flags] {source_directory} 465 make 466 467 468### ARMv7s (32-bit) 469 470**gas-preprocessor.pl required** 471 472The following scripts demonstrate how to build libjpeg-turbo to run on the 473iPhone 5/iPad 4th Generation and newer: 474 475#### Xcode 4.5-4.6 (LLVM-GCC) 476 477 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform 478 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) 479 export CFLAGS="-Wall -mfloat-abi=softfp -march=armv7s -mcpu=swift -mtune=swift -mfpu=neon -miphoneos-version-min=6.0" 480 481 cd {build_directory} 482 483 cat <<EOF >toolchain.cmake 484 set(CMAKE_SYSTEM_NAME Darwin) 485 set(CMAKE_SYSTEM_PROCESSOR arm) 486 set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2) 487 EOF 488 489 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ 490 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \ 491 [additional CMake flags] {source_directory} 492 make 493 494#### Xcode 5 and later (Clang) 495 496Same as the ARMv7 build procedure for Xcode 5 and later, except replace the 497compiler flags as follows: 498 499 export CFLAGS="-Wall -mfloat-abi=softfp -arch armv7s -miphoneos-version-min=6.0" 500 501 502### ARMv8 (64-bit) 503 504**gas-preprocessor.pl required if using Xcode < 6** 505 506The following script demonstrates how to build libjpeg-turbo to run on the 507iPhone 5S/iPad Mini 2/iPad Air and newer. 508 509 IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform 510 IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) 511 export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=7.0 -funwind-tables" 512 513 cd {build_directory} 514 515 cat <<EOF >toolchain.cmake 516 set(CMAKE_SYSTEM_NAME Darwin) 517 set(CMAKE_SYSTEM_PROCESSOR aarch64) 518 set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang) 519 EOF 520 521 cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ 522 -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \ 523 [additional CMake flags] {source_directory} 524 make 525 526Once built, lipo can be used to combine the ARMv7, v7s, and/or v8 variants into 527a universal library. 528 529 530Building libjpeg-turbo for Android 531---------------------------------- 532 533Building libjpeg-turbo for Android platforms requires v13b or later of the 534[Android NDK](https://developer.android.com/tools/sdk/ndk). 535 536 537### ARMv7 (32-bit) 538 539The following is a general recipe script that can be modified for your specific 540needs. 541 542 # Set these variables to suit your needs 543 NDK_PATH={full path to the NDK directory-- for example, 544 /opt/android/android-ndk-r16b} 545 TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r16b and earlier, 546 and "clang" must be used with NDK r17c and later} 547 ANDROID_VERSION={the minimum version of Android to support-- for example, 548 "16", "19", etc.} 549 550 cd {build_directory} 551 cmake -G"Unix Makefiles" \ 552 -DANDROID_ABI=armeabi-v7a \ 553 -DANDROID_ARM_MODE=arm \ 554 -DANDROID_PLATFORM=android-${ANDROID_VERSION} \ 555 -DANDROID_TOOLCHAIN=${TOOLCHAIN} \ 556 -DCMAKE_ASM_FLAGS="--target=arm-linux-androideabi${ANDROID_VERSION}" \ 557 -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \ 558 [additional CMake flags] {source_directory} 559 make 560 561 562### ARMv8 (64-bit) 563 564The following is a general recipe script that can be modified for your specific 565needs. 566 567 # Set these variables to suit your needs 568 NDK_PATH={full path to the NDK directory-- for example, 569 /opt/android/android-ndk-r16b} 570 TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier, 571 and "clang" must be used with NDK r17c and later} 572 ANDROID_VERSION={the minimum version of Android to support. "21" or later 573 is required for a 64-bit build.} 574 575 cd {build_directory} 576 cmake -G"Unix Makefiles" \ 577 -DANDROID_ABI=arm64-v8a \ 578 -DANDROID_ARM_MODE=arm \ 579 -DANDROID_PLATFORM=android-${ANDROID_VERSION} \ 580 -DANDROID_TOOLCHAIN=${TOOLCHAIN} \ 581 -DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${ANDROID_VERSION}" \ 582 -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \ 583 [additional CMake flags] {source_directory} 584 make 585 586 587### x86 (32-bit) 588 589The following is a general recipe script that can be modified for your specific 590needs. 591 592 # Set these variables to suit your needs 593 NDK_PATH={full path to the NDK directory-- for example, 594 /opt/android/android-ndk-r16b} 595 TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier, 596 and "clang" must be used with NDK r17c and later} 597 ANDROID_VERSION={The minimum version of Android to support-- for example, 598 "16", "19", etc.} 599 600 cd {build_directory} 601 cmake -G"Unix Makefiles" \ 602 -DANDROID_ABI=x86 \ 603 -DANDROID_PLATFORM=android-${ANDROID_VERSION} \ 604 -DANDROID_TOOLCHAIN=${TOOLCHAIN} \ 605 -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \ 606 [additional CMake flags] {source_directory} 607 make 608 609 610### x86-64 (64-bit) 611 612The following is a general recipe script that can be modified for your specific 613needs. 614 615 # Set these variables to suit your needs 616 NDK_PATH={full path to the NDK directory-- for example, 617 /opt/android/android-ndk-r16b} 618 TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier, 619 and "clang" must be used with NDK r17c and later} 620 ANDROID_VERSION={the minimum version of Android to support. "21" or later 621 is required for a 64-bit build.} 622 623 cd {build_directory} 624 cmake -G"Unix Makefiles" \ 625 -DANDROID_ABI=x86_64 \ 626 -DANDROID_PLATFORM=android-${ANDROID_VERSION} \ 627 -DANDROID_TOOLCHAIN=${TOOLCHAIN} \ 628 -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \ 629 [additional CMake flags] {source_directory} 630 make 631 632 633Advanced CMake Options 634---------------------- 635 636To list and configure other CMake options not specifically mentioned in this 637guide, run 638 639 ccmake {source_directory} 640 641or 642 643 cmake-gui {source_directory} 644 645from the build directory after initially configuring the build. CCMake is a 646text-based interactive version of CMake, and CMake-GUI is a GUI version. Both 647will display all variables that are relevant to the libjpeg-turbo build, their 648current values, and a help string describing what they do. 649 650 651Installing libjpeg-turbo 652======================== 653 654You can use the build system to install libjpeg-turbo (as opposed to creating 655an installer package.) To do this, run `make install` or `nmake install` 656(or build the "install" target in the Visual Studio IDE.) Running 657`make uninstall` or `nmake uninstall` (or building the "uninstall" target in 658the Visual Studio IDE) will uninstall libjpeg-turbo. 659 660The `CMAKE_INSTALL_PREFIX` CMake variable can be modified in order to install 661libjpeg-turbo into a directory of your choosing. If you don't specify 662`CMAKE_INSTALL_PREFIX`, then the default is: 663 664**c:\libjpeg-turbo**<br> 665Visual Studio 32-bit build 666 667**c:\libjpeg-turbo64**<br> 668Visual Studio 64-bit build 669 670**c:\libjpeg-turbo-gcc**<br> 671MinGW 32-bit build 672 673**c:\libjpeg-turbo-gcc64**<br> 674MinGW 64-bit build 675 676**/opt/libjpeg-turbo**<br> 677Un*x 678 679The default value of `CMAKE_INSTALL_PREFIX` causes the libjpeg-turbo files to 680be installed with a directory structure resembling that of the official 681libjpeg-turbo binary packages. Changing the value of `CMAKE_INSTALL_PREFIX` 682(for instance, to **/usr/local**) causes the libjpeg-turbo files to be 683installed with a directory structure that conforms to GNU standards. 684 685The `CMAKE_INSTALL_BINDIR`, `CMAKE_INSTALL_DATAROOTDIR`, 686`CMAKE_INSTALL_DOCDIR`, `CMAKE_INSTALL_INCLUDEDIR`, `CMAKE_INSTALL_JAVADIR`, 687`CMAKE_INSTALL_LIBDIR`, and `CMAKE_INSTALL_MANDIR` CMake variables allow a 688finer degree of control over where specific files in the libjpeg-turbo 689distribution should be installed. These directory variables can either be 690specified as absolute paths or as paths relative to `CMAKE_INSTALL_PREFIX` (for 691instance, setting `CMAKE_INSTALL_DOCDIR` to **doc** would cause the 692documentation to be installed in **${CMAKE\_INSTALL\_PREFIX}/doc**.) If a 693directory variable contains the name of another directory variable in angle 694brackets, then its final value will depend on the final value of that other 695variable. For instance, the default value of `CMAKE_INSTALL_MANDIR` is 696**\<CMAKE\_INSTALL\_DATAROOTDIR\>/man**. 697 698NOTE: If setting one of these directory variables to a relative path using the 699CMake command line, you must specify that the variable is of type `PATH`. 700For example: 701 702 cmake -G"{generator type}" -DCMAKE_INSTALL_LIBDIR:PATH=lib {source_directory} 703 704Otherwise, CMake will assume that the path is relative to the build directory 705rather than the install directory. 706 707 708Creating Distribution Packages 709============================== 710 711The following commands can be used to create various types of distribution 712packages: 713 714 715Linux 716----- 717 718 make rpm 719 720Create Red Hat-style binary RPM package. Requires RPM v4 or later. 721 722 make srpm 723 724This runs `make dist` to create a pristine source tarball, then creates a 725Red Hat-style source RPM package from the tarball. Requires RPM v4 or later. 726 727 make deb 728 729Create Debian-style binary package. Requires dpkg. 730 731 732Mac 733--- 734 735 make dmg 736 737Create Mac package/disk image. This requires pkgbuild and productbuild, which 738are installed by default on OS X 10.7 and later and which can be obtained by 739installing Xcode 3.2.6 (with the "Unix Development" option) on OS X 10.6. 740Packages built in this manner can be installed on OS X 10.5 and later, but they 741must be built on OS X 10.6 or later. 742 743 make udmg 744 745This creates a Mac package/disk image that contains universal x86-64/i386/ARM 746binaries. The following CMake variables control which architectures are 747included in the universal binaries. Setting any of these variables to an empty 748string excludes that architecture from the package. 749 750* `OSX_32BIT_BUILD`: Directory containing an i386 (32-bit) Mac build of 751 libjpeg-turbo (default: *{source_directory}*/osxx86) 752* `IOS_ARMV7_BUILD`: Directory containing an ARMv7 (32-bit) iOS build of 753 libjpeg-turbo (default: *{source_directory}*/iosarmv7) 754* `IOS_ARMV7S_BUILD`: Directory containing an ARMv7s (32-bit) iOS build of 755 libjpeg-turbo (default: *{source_directory}*/iosarmv7s) 756* `IOS_ARMV8_BUILD`: Directory containing an ARMv8 (64-bit) iOS build of 757 libjpeg-turbo (default: *{source_directory}*/iosarmv8) 758 759You should first use CMake to configure i386, ARMv7, ARMv7s, and/or ARMv8 760sub-builds of libjpeg-turbo (see "Build Recipes" and "Building libjpeg-turbo 761for iOS" above) in build directories that match those specified in the 762aforementioned CMake variables. Next, configure the primary build of 763libjpeg-turbo as an out-of-tree build, and build it. Once the primary build 764has been built, run `make udmg` from the build directory. The packaging system 765will build the sub-builds, use lipo to combine them into a single set of 766universal binaries, then package the universal binaries in the same manner as 767`make dmg`. 768 769 770Cygwin 771------ 772 773 make cygwinpkg 774 775Build a Cygwin binary package. 776 777 778Windows 779------- 780 781If using NMake: 782 783 cd {build_directory} 784 nmake installer 785 786If using MinGW: 787 788 cd {build_directory} 789 make installer 790 791If using the Visual Studio IDE, build the "installer" target. 792 793The installer package (libjpeg-turbo-*{version}*[-gcc|-vc][64].exe) will be 794located under *{build_directory}*. If building using the Visual Studio IDE, 795then the installer package will be located in a subdirectory with the same name 796as the configuration you built (such as *{build_directory}*\Debug\ or 797*{build_directory}*\Release\). 798 799Building a Windows installer requires the 800[Nullsoft Install System](http://nsis.sourceforge.net/). makensis.exe should 801be in your `PATH`. 802 803 804Regression testing 805================== 806 807The most common way to test libjpeg-turbo is by invoking `make test` (Un*x) or 808`nmake test` (Windows command line) or by building the "RUN_TESTS" target 809(Visual Studio IDE), once the build has completed. This runs a series of tests 810to ensure that mathematical compatibility has been maintained between 811libjpeg-turbo and libjpeg v6b. This also invokes the TurboJPEG unit tests, 812which ensure that the colorspace extensions, YUV encoding, decompression 813scaling, and other features of the TurboJPEG C and Java APIs are working 814properly (and, by extension, that the equivalent features of the underlying 815libjpeg API are also working.) 816 817Invoking `make testclean` (Un*x) or `nmake testclean` (Windows command line) or 818building the "testclean" target (Visual Studio IDE) will clean up the output 819images generated by the tests. 820 821On Un*x platforms, more extensive tests of the TurboJPEG C and Java wrappers 822can be run by invoking `make tjtest`. These extended TurboJPEG tests 823essentially iterate through all of the available features of the TurboJPEG APIs 824that are not covered by the TurboJPEG unit tests (including the lossless 825transform options) and compare the images generated by each feature to images 826generated using the equivalent feature in the libjpeg API. The extended 827TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers, 828not in the underlying libjpeg API library. 829