- [CMake](http://www.cmake.org) v2.8.12 or later
-- [NASM](http://www.nasm.us) or [YASM](http://yasm.tortall.net)
+- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net)
(if building x86 or x86-64 SIMD extensions)
- * If using NASM, 2.10 or later is required.
- * If using NASM, 2.10 or later (except 2.11.08) is required for an x86-64 Mac
- build (2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code
- when building macho64 objects.)
- * If using YASM, 1.2.0 or later is required.
- * If building on macOS, NASM or YASM can be obtained from
+ * If using NASM, 2.13 or later is required.
+ * If using Yasm, 1.2.0 or later is required.
+ * If building on macOS, NASM or Yasm can be obtained from
[MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
Mac executables or shared libraries that statically link with
- libjpeg-turbo, then NASM 2.14 or later or YASM must be used when
+ libjpeg-turbo, then NASM 2.14 or later or Yasm must be used when
building libjpeg-turbo.
- * If building on Windows, **nasm.exe**/**yasm.exe** should be in your `PATH`.
- * NASM and YASM are located in the CRB (Code Ready Builder) repository on
- Red Hat Enterprise Linux 8 and in the PowerTools repository on CentOS 8,
- which is not enabled by default.
-
- The binary RPMs released by the NASM project do not work on older Linux
- systems, such as Red Hat Enterprise Linux 5. On such systems, you can easily
- build and install NASM from a source RPM by downloading one of the SRPMs from
-
- <http://www.nasm.us/pub/nasm/releasebuilds>
-
- and executing the following as root:
-
- ARCH=`uname -m`
- rpmbuild --rebuild nasm-{version}.src.rpm
- rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
-
- NOTE: the NASM build will fail if texinfo is not installed.
-
+ * If NASM or Yasm is not in your `PATH`, then you can specify the full path
+ to the assembler by using either the `CMAKE_ASM_NASM_COMPILER` CMake
+ variable or the `ASM_NASM` environment variable. On Windows, use forward
+ slashes rather than backslashes in the path (for example,
+ **c:/nasm/nasm.exe**).
+ * NASM and Yasm are located in the CRB (Code Ready Builder) or PowerTools
+ repository on Red Hat Enterprise Linux 8+ and derivatives, which is not
+ enabled by default.
### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin)
- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
required. Most modern Linux distributions, as well as Solaris 10 and later,
- include JDK or OpenJDK. On OS X 10.5 and 10.6, it will be necessary to
- install the Java Developer Package, which can be downloaded from
- <http://developer.apple.com/downloads> (Apple ID required.) For other
- systems, you can obtain the Oracle Java Development Kit from
+ include JDK or OpenJDK. For other systems, you can obtain the Oracle Java
+ Development Kit from
<http://www.oracle.com/technetwork/java/javase/downloads>.
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
- Microsoft Visual C++ 2005 or later
If you don't already have Visual C++, then the easiest way to get it is by
- installing the
- [Windows SDK](http://msdn.microsoft.com/en-us/windows/bb980924.aspx).
- The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
- everything necessary to build libjpeg-turbo.
-
- * You can also use Microsoft Visual Studio Express/Community Edition, which
- is a free download. (NOTE: versions prior to 2012 can only be used to
- build 32-bit code.)
+ installing
+ [Visual Studio Community Edition](https://visualstudio.microsoft.com),
+ which includes everything necessary to build libjpeg-turbo.
+
+ * You can also download and install the standalone Windows SDK (for Windows 7
+ or later), which includes command-line versions of the 32-bit and 64-bit
+ Visual C++ compilers.
* If you intend to build libjpeg-turbo from the command line, then add the
appropriate compiler and SDK directories to the `INCLUDE`, `LIB`, and
`PATH` environment variables. This is generally accomplished by
- executing `vcvars32.bat` or `vcvars64.bat` and `SetEnv.cmd`.
- `vcvars32.bat` and `vcvars64.bat` are part of Visual C++ and are located in
- the same directory as the compiler. `SetEnv.cmd` is part of the Windows
- SDK. You can pass optional arguments to `SetEnv.cmd` to specify a 32-bit
- or 64-bit build environment.
+ executing `vcvars32.bat` or `vcvars64.bat`, which are located in the same
+ directory as the compiler.
+ * If built with Visual C++ 2015 or later, the libjpeg-turbo static libraries
+ cannot be used with earlier versions of Visual C++, and vice versa.
+ * The libjpeg API DLL (**jpeg{version}.dll**) will depend on the C run-time
+ DLLs corresponding to the version of Visual C++ that was used to build it.
... OR ...
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
+Sub-Project Builds
+------------------
+
+The libjpeg-turbo build system does not support being included as a sub-project
+using the CMake `add_subdirectory()` function. Use the CMake
+`ExternalProject_Add()` function instead.
+
+
Out-of-Tree Builds
------------------
directory. For in-tree builds, these directories are the same.
+Ninja
+-----
+
+If using Ninja, then replace `make` or `nmake` with `ninja`, and replace the
+CMake generator (specified with the `-G` option) with `Ninja`, in all of the
+procedures and recipes below.
+
+
Build Procedure
---------------
information about libjpeg v7 and v8 emulation.
-### In-Memory Source/Destination Managers
-
-When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
-the CMake command line to build a version of libjpeg-turbo that lacks the
-`jpeg_mem_src()` and `jpeg_mem_dest()` functions. These functions were not
-part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
-conformance with those APIs. See [README.md](README.md) for more information.
-
-
### Arithmetic Coding Support
Since the patent on arithmetic coding has expired, this functionality has been
-------------
-### 32-bit Build on 64-bit Linux/Unix/Mac
+### 32-bit Build on 64-bit Linux/Unix
Use export/setenv to set the following environment variables before running
CMake:
cd {build_directory}
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
+ -DCMAKE_INSTALL_PREFIX={install_path} \
[additional CMake flags] {source_directory}
make
+*{install\_path}* is the path under which the libjpeg-turbo binaries should be
+installed.
+
### 64-bit MinGW Build on Un*x (including Mac and Cygwin)
cd {build_directory}
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
+ -DCMAKE_INSTALL_PREFIX={install_path} \
[additional CMake flags] {source_directory}
make
+*{install\_path}* is the path under which the libjpeg-turbo binaries should be
+installed.
+
Building libjpeg-turbo for iOS
------------------------------
for these platforms.
-### Additional build requirements
-
-- For configurations that require [gas-preprocessor.pl]
- (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl),
- it should be installed in your `PATH`.
-
-
-### Armv7 (32-bit)
-
-**gas-preprocessor.pl required**
-
-The following scripts demonstrate how to build libjpeg-turbo to run on the
-iPhone 3GS-4S/iPad 1st-3rd Generation and newer:
-
-#### Xcode 4.2 and earlier (LLVM-GCC)
-
- IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform
- IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
- export CFLAGS="-mfloat-abi=softfp -march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -miphoneos-version-min=3.0"
-
- cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Darwin)
- set(CMAKE_SYSTEM_PROCESSOR arm)
- set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
- [additional CMake flags] {source_directory}
- make
-
-#### Xcode 4.3-4.6 (LLVM-GCC)
-
-Same as above, but replace the first line with:
-
- IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
-
-#### Xcode 5 and later (Clang)
-
- IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
- IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
- export CFLAGS="-mfloat-abi=softfp -arch armv7 -miphoneos-version-min=3.0"
- export ASMFLAGS="-no-integrated-as"
-
- cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Darwin)
- set(CMAKE_SYSTEM_PROCESSOR arm)
- set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
- [additional CMake flags] {source_directory}
- make
-
-
-### Armv7s (32-bit)
-
-**gas-preprocessor.pl required**
-
-The following scripts demonstrate how to build libjpeg-turbo to run on the
-iPhone 5/iPad 4th Generation and newer:
-
-#### Xcode 4.5-4.6 (LLVM-GCC)
-
- IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
- IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
- export CFLAGS="-Wall -mfloat-abi=softfp -march=armv7s -mcpu=swift -mtune=swift -mfpu=neon -miphoneos-version-min=6.0"
-
- cd {build_directory}
-
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Darwin)
- set(CMAKE_SYSTEM_PROCESSOR arm)
- set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
- -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
- [additional CMake flags] {source_directory}
- make
-
-#### Xcode 5 and later (Clang)
-
-Same as the Armv7 build procedure for Xcode 5 and later, except replace the
-compiler flags as follows:
-
- export CFLAGS="-Wall -mfloat-abi=softfp -arch armv7s -miphoneos-version-min=6.0"
-
-
### Armv8 (64-bit)
-**gas-preprocessor.pl required if using Xcode < 6**
+**Xcode 5 or later required, Xcode 6.3.x or later recommended**
The following script demonstrates how to build libjpeg-turbo to run on the
iPhone 5S/iPad Mini 2/iPad Air and newer.
[additional CMake flags] {source_directory}
make
-Once built, lipo can be used to combine the Armv7, v7s, and/or v8 variants into
-a universal library.
+Replace `iPhoneOS` with `iPhoneSimulator` and `-miphoneos-version-min` with
+`-miphonesimulator-version-min` to build libjpeg-turbo for the iOS simulator on
+Macs with Apple silicon CPUs.
Building libjpeg-turbo for Android
### Armv7 (32-bit)
+**NDK r19 or later with Clang recommended**
+
The following is a general recipe script that can be modified for your specific
needs.
### Armv8 (64-bit)
+**Clang recommended**
+
The following is a general recipe script that can be modified for your specific
needs.
make dmg
Create Mac package/disk image. This requires pkgbuild and productbuild, which
-are installed by default on OS X 10.7 and later and which can be obtained by
-installing Xcode 3.2.6 (with the "Unix Development" option) on OS X 10.6.
-Packages built in this manner can be installed on OS X 10.5 and later, but they
-must be built on OS X 10.6 or later.
-
- make udmg
-
-This creates a Mac package/disk image that contains universal x86-64/i386/Arm
-binaries. The following CMake variables control which architectures are
-included in the universal binaries. Setting any of these variables to an empty
-string excludes that architecture from the package.
-
-* `OSX_32BIT_BUILD`: Directory containing an i386 (32-bit) Mac build of
- libjpeg-turbo (default: *{source_directory}*/osxx86)
-* `IOS_ARMV7_BUILD`: Directory containing an Armv7 (32-bit) iOS build of
- libjpeg-turbo (default: *{source_directory}*/iosarmv7)
-* `IOS_ARMV7S_BUILD`: Directory containing an Armv7s (32-bit) iOS build of
- libjpeg-turbo (default: *{source_directory}*/iosarmv7s)
-* `IOS_ARMV8_BUILD`: Directory containing an Armv8 (64-bit) iOS build of
- libjpeg-turbo (default: *{source_directory}*/iosarmv8)
-
-You should first use CMake to configure i386, Armv7, Armv7s, and/or Armv8
-sub-builds of libjpeg-turbo (see "Build Recipes" and "Building libjpeg-turbo
-for iOS" above) in build directories that match those specified in the
-aforementioned CMake variables. Next, configure the primary build of
-libjpeg-turbo as an out-of-tree build, and build it. Once the primary build
-has been built, run `make udmg` from the build directory. The packaging system
-will build the sub-builds, use lipo to combine them into a single set of
-universal binaries, then package the universal binaries in the same manner as
-`make dmg`.
-
-
-Cygwin
-------
-
- make cygwinpkg
-
-Build a Cygwin binary package.
+are installed by default on OS X/macOS 10.7 and later.
+
+In order to create a Mac package/disk image that contains universal
+x86-64/Arm binaries, set the following CMake variable:
+
+* `ARMV8_BUILD`: Directory containing an Armv8 (64-bit) iOS or macOS build of
+ libjpeg-turbo to include in the universal binaries
+
+You should first use CMake to configure an Armv8 sub-build of libjpeg-turbo
+(see "Building libjpeg-turbo for iOS" above, if applicable) in a build
+directory that matches the one specified in the aforementioned CMake variable.
+Next, configure the primary (x86-64) build of libjpeg-turbo as an out-of-tree
+build, specifying the aforementioned CMake variable, and build it. Once the
+primary build has been built, run `make dmg` from the build directory. The
+packaging system will build the sub-build, use lipo to combine it with the
+primary build into a single set of universal binaries, then package the
+universal binaries.
Windows