blob: 0b525e93fc481f589411d7cce4d73c15dfcce783 [file] [log] [blame]
DRC68fef832010-02-16 05:29:10 +00001*******************************************************************************
DRCf32640e2013-03-23 09:57:03 +00002** Building on Un*x Platforms (including Cygwin and OS X)
DRC68fef832010-02-16 05:29:10 +00003*******************************************************************************
4
DRCcc243742010-10-16 09:22:43 +00005
DRC68fef832010-02-16 05:29:10 +00006==================
7Build Requirements
8==================
9
10-- autoconf 2.56 or later
DRC68fef832010-02-16 05:29:10 +000011-- automake 1.7 or later
DRC68fef832010-02-16 05:29:10 +000012-- libtool 1.4 or later
DRCf32640e2013-03-23 09:57:03 +000013 * If using Xcode 4.3 or later on OS X, autoconf and automake are no longer
14 provided. The easiest way to obtain them is from MacPorts
15 (http://www.macports.org/).
DRC68fef832010-02-16 05:29:10 +000016
DRC94755ce2011-10-19 05:13:27 +000017-- NASM (if building x86 or x86-64 SIMD extensions)
DRC254937b2011-04-16 13:35:35 +000018 * 0.98, or 2.01 or later is required for a 32-bit build
19 * NASM 2.00 or later is required for a 64-bit build
DRC9026b372011-04-16 13:37:22 +000020 * NASM 2.07 or later is required for a 64-bit build on OS X. This can be
DRC0dedd1a2010-07-02 09:20:12 +000021 obtained from MacPorts (http://www.macports.org/).
DRC68fef832010-02-16 05:29:10 +000022
DRC254937b2011-04-16 13:35:35 +000023 The binary RPMs released by the NASM project do not work on older Linux
24 systems, such as Red Hat Enterprise Linux 4. On such systems, you can
25 easily build and install NASM from a source RPM by downloading one of the
26 SRPMs from
27
28 http://www.nasm.us/pub/nasm/releasebuilds
29
30 and executing the following as root:
DRC68fef832010-02-16 05:29:10 +000031
32 ARCH=`uname -m`
DRC254937b2011-04-16 13:35:35 +000033 rpmbuild --rebuild nasm-{version}.src.rpm
34 rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
DRC68fef832010-02-16 05:29:10 +000035
DRC254937b2011-04-16 13:35:35 +000036 NOTE: the NASM build will fail if texinfo is not installed.
DRCc3f4ac02010-02-19 21:51:26 +000037
DRC8f870c22010-02-24 00:30:00 +000038-- GCC v4.1 or later recommended for best performance
DRCf32640e2013-03-23 09:57:03 +000039 * Beginning with Xcode 4, Apple stopped distributing GCC and switched to
40 the LLVM compiler. Xcode v4.0 through 4.6 provides a GCC front end called
41 LLVM-GCC. Unfortunately, as of this writing, neither LLVM-GCC nor the
42 LLVM (clang) compiler produce optimal performance with libjpeg-turbo.
43 Building libjpeg-turbo with LLVM-GCC v4.2 results in a 10% performance
44 degradation when compressing using 64-bit code, relative to building
45 libjpeg-turbo with GCC v4.2. Building libjpeg-turbo with LLVM (clang)
46 results in a 20% performance degradation when compressing using 64-bit
47 code, relative to building libjpeg-turbo with GCC v4.2. If you are
48 running Snow Leopard or earlier, it is suggested that you continue to use
49 Xcode v3.2.6, which provides GCC v4.2. If you are using Lion or later, it
50 is suggested that you install Apple GCC v4.2 through MacPorts.
DRC68fef832010-02-16 05:29:10 +000051
DRC5039d732013-01-21 23:42:12 +000052-- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
DRC279bd342011-04-02 05:17:12 +000053 required. Some systems, such as OS X 10.4, Solaris 10 and later, and Red
54 Hat Enterprise Linux 5 and later, have this pre-installed. On OS X 10.5 and
55 later, it will be necessary to install the Java Developer Package, which can
56 be downloaded from http://connect.apple.com. For systems that do not have a
57 JDK installed, you can obtain the Oracle Java Development Kit from
58 http://www.java.com.
DRCf8e00552011-02-04 11:06:36 +000059
DRCcc243742010-10-16 09:22:43 +000060
61==================
62Out-of-Tree Builds
63==================
64
65Binary objects, libraries, and executables are generated in the same directory
66from which configure was executed (the "binary directory"), and this directory
67need not necessarily be the same as the libjpeg-turbo source directory. You
68can create multiple independent binary directories, in which different versions
69of libjpeg-turbo can be built from the same source tree using different
70compilers or settings. In the sections below, {build_directory} refers to the
71binary directory, whereas {source_directory} refers to the libjpeg-turbo source
72directory. For in-tree builds, these directories are the same.
73
74
DRC68fef832010-02-16 05:29:10 +000075======================
76Building libjpeg-turbo
77======================
78
DRC5039d732013-01-21 23:42:12 +000079The following procedure will build libjpeg-turbo on Linux, FreeBSD, Cygwin, and
80Solaris/x86 systems (on Solaris, this generates a 32-bit library. See below
81for 64-bit build instructions.)
DRC68fef832010-02-16 05:29:10 +000082
DRCcc243742010-10-16 09:22:43 +000083 cd {source_directory}
DRC68fef832010-02-16 05:29:10 +000084 autoreconf -fiv
DRCcc243742010-10-16 09:22:43 +000085 cd {build_directory}
DRC98dbe912010-11-04 22:22:30 +000086 sh {source_directory}/configure [additional configure flags]
DRC68fef832010-02-16 05:29:10 +000087 make
88
DRCfde862b2013-02-11 03:38:53 +000089NOTE: Running autoreconf in the source directory is usually only necessary if
90building libjpeg-turbo from the SVN repository.
DRC68fef832010-02-16 05:29:10 +000091
92This will generate the following files under .libs/
93
94 libjpeg.a
DRC5039d732013-01-21 23:42:12 +000095 Static link library for the libjpeg API
DRC68fef832010-02-16 05:29:10 +000096
DRC5039d732013-01-21 23:42:12 +000097 libjpeg.so.{version} (Linux, Unix)
DRCcc243742010-10-16 09:22:43 +000098 libjpeg.{version}.dylib (OS X)
DRC81543312010-10-18 07:23:58 +000099 cygjpeg-{version}.dll (Cygwin)
DRC5039d732013-01-21 23:42:12 +0000100 Shared library for the libjpeg API
DRC68fef832010-02-16 05:29:10 +0000101
DRC5039d732013-01-21 23:42:12 +0000102 By default, {version} is 62.1.0, 7.1.0, or 8.0.2, depending on whether
103 libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin,
104 {version} is 62, 7, or 8.
105
106 libjpeg.so (Linux, Unix)
DRC68fef832010-02-16 05:29:10 +0000107 libjpeg.dylib (OS X)
DRC5039d732013-01-21 23:42:12 +0000108 Development symlink for the libjpeg API
109
DRC81543312010-10-18 07:23:58 +0000110 libjpeg.dll.a (Cygwin)
DRC5039d732013-01-21 23:42:12 +0000111 Import library for the libjpeg API
DRC68fef832010-02-16 05:29:10 +0000112
113 libturbojpeg.a
DRC5039d732013-01-21 23:42:12 +0000114 Static link library for the TurboJPEG API
DRC68fef832010-02-16 05:29:10 +0000115
DRC5039d732013-01-21 23:42:12 +0000116 libturbojpeg.so.0.0.0 (Linux, Unix)
117 libturbojpeg.0.0.0.dylib (OS X)
118 cygturbojpeg-0.dll (Cygwin)
119 Shared library for the TurboJPEG API
120
121 libturbojpeg.so (Linux, Unix)
DRC68fef832010-02-16 05:29:10 +0000122 libturbojpeg.dylib (OS X)
DRC5039d732013-01-21 23:42:12 +0000123 Development symlink for the TurboJPEG API
DRC81543312010-10-18 07:23:58 +0000124
125 libturbojpeg.dll.a (Cygwin)
DRC5039d732013-01-21 23:42:12 +0000126 Import library for the TurboJPEG API
DRC81543312010-10-18 07:23:58 +0000127
128
DRC30913542012-01-27 09:53:33 +0000129libjpeg v7 or v8 API/ABI Emulation
130----------------------------------
DRC81543312010-10-18 07:23:58 +0000131
132Add --with-jpeg7 to the configure command line to build a version of
DRC30913542012-01-27 09:53:33 +0000133libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add --with-jpeg8 to
134the configure command to build a version of libjpeg-turbo that is
135API/ABI-compatible with libjpeg v8. See README-turbo.txt for more information
136on libjpeg v7 and v8 emulation.
DRC81543312010-10-18 07:23:58 +0000137
DRC68fef832010-02-16 05:29:10 +0000138
DRC5039d732013-01-21 23:42:12 +0000139In-Memory Source/Destination Managers
140-------------------------------------
141
142When using libjpeg v6b or v7 API/ABI emulation, add --without-mem-srcdst to the
143configure command line to build a version of libjpeg-turbo that lacks the
144jpeg_mem_src() and jpeg_mem_dest() functions. These functions were not part of
145the original libjpeg v6b and v7 APIs, so removing them ensures strict
146conformance with those APIs. See README-turbo.txt for more information.
147
148
DRC245cfdf2010-11-23 17:11:06 +0000149Arithmetic Coding Support
150-------------------------
151
152Since the patent on arithmetic coding has expired, this functionality has been
153included in this release of libjpeg-turbo. libjpeg-turbo's implementation is
DRCf38eee02011-02-18 07:00:38 +0000154based on the implementation in libjpeg v8, but it works when emulating libjpeg
DRC245cfdf2010-11-23 17:11:06 +0000155v7 or v6b as well. The default is to enable both arithmetic encoding and
156decoding, but those who have philosophical objections to arithmetic coding can
157add --without-arith-enc or --without-arith-dec to the configure command line to
158disable encoding or decoding (respectively.)
159
DRC68fef832010-02-16 05:29:10 +0000160
DRC5039d732013-01-21 23:42:12 +0000161TurboJPEG Java Wrapper
162----------------------
DRC88f54a42011-04-01 01:21:22 +0000163Add --with-java to the configure command line to incorporate an optional Java
DRC5039d732013-01-21 23:42:12 +0000164Native Interface wrapper into the TurboJPEG shared library and build the Java
165front-end classes to support it. This allows the TurboJPEG shared library to
166be used directly from Java applications. See java/README for more details.
DRC88f54a42011-04-01 01:21:22 +0000167
168You can set the JAVAC, JAR, and JAVA configure variables to specify
169alternate commands for javac, jar, and java (respectively.) You can also
170set the JAVACFLAGS configure variable to specify arguments that should be
171passed to the Java compiler when building the front-end classes, and JNI_CFLAGS
172to specify arguments that should be passed to the C compiler when building the
173JNI wrapper. Run 'configure --help' for more details.
DRCf8e00552011-02-04 11:06:36 +0000174
175
DRC68fef832010-02-16 05:29:10 +0000176========================
177Installing libjpeg-turbo
178========================
179
180If you intend to install these libraries and the associated header files, then
181replace 'make' in the instructions above with
182
183 make install prefix={base dir} libdir={library directory}
184
185For example,
186
187 make install prefix=/usr/local libdir=/usr/local/lib64
188
189will install the header files in /usr/local/include and the library files in
190/usr/local/lib64. If 'prefix' and 'libdir' are not specified, then the default
191is to install the header files in /opt/libjpeg-turbo/include and the library
192files in /opt/libjpeg-turbo/lib.
193
194NOTE: You can specify a prefix of /usr and a libdir of, for instance,
195/usr/lib64 to overwrite the system's version of libjpeg. If you do this,
196however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before
197overwriting it. It is recommended that you instead install libjpeg-turbo into
DRC5039d732013-01-21 23:42:12 +0000198a non-system directory and manipulate the LD_LIBRARY_PATH or create symlinks
DRC68fef832010-02-16 05:29:10 +0000199to force applications to use libjpeg-turbo instead of libjpeg. See
200README-turbo.txt for more information.
201
DRCcc243742010-10-16 09:22:43 +0000202
DRC68fef832010-02-16 05:29:10 +0000203=============
204Build Recipes
205=============
206
DRCcc243742010-10-16 09:22:43 +0000207
DRC5039d732013-01-21 23:42:12 +000020832-bit Build on 64-bit Linux
209----------------------------
DRC68fef832010-02-16 05:29:10 +0000210
DRCca5e7d12010-02-17 02:25:06 +0000211Add
DRC68fef832010-02-16 05:29:10 +0000212
DRC2e4d0442011-02-08 01:18:37 +0000213 --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
DRC68fef832010-02-16 05:29:10 +0000214
215to the configure command line.
216
217
DRC5039d732013-01-21 23:42:12 +000021864-bit Build on 64-bit OS X
219---------------------------
DRC68fef832010-02-16 05:29:10 +0000220
DRCca5e7d12010-02-17 02:25:06 +0000221Add
DRC68fef832010-02-16 05:29:10 +0000222
DRC0dedd1a2010-07-02 09:20:12 +0000223 --host x86_64-apple-darwin NASM=/opt/local/bin/nasm
DRC68fef832010-02-16 05:29:10 +0000224
DRC7bac07b2010-04-10 05:53:35 +0000225to the configure command line. NASM 2.07 or later from MacPorts must be
226installed.
DRC68fef832010-02-16 05:29:10 +0000227
228
DRC5039d732013-01-21 23:42:12 +000022932-bit Build on 64-bit OS X
230---------------------------
DRC68fef832010-02-16 05:29:10 +0000231
DRCca5e7d12010-02-17 02:25:06 +0000232Add
DRC68fef832010-02-16 05:29:10 +0000233
DRC5950c5d2012-06-28 23:22:03 +0000234 --host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32
DRC68fef832010-02-16 05:29:10 +0000235
236to the configure command line.
237
238
DRC5039d732013-01-21 23:42:12 +000023964-bit Backward-Compatible Build on 64-bit OS X
240-----------------------------------------------
DRC68fef832010-02-16 05:29:10 +0000241
DRCca5e7d12010-02-17 02:25:06 +0000242Add
DRC68fef832010-02-16 05:29:10 +0000243
DRC0dedd1a2010-07-02 09:20:12 +0000244 --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
245 CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
246 -mmacosx-version-min=10.4 -O3' \
DRC0dedd1a2010-07-02 09:20:12 +0000247 LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
248 -mmacosx-version-min=10.4'
249
DRC575c3422010-07-08 07:01:20 +0000250to the configure command line. The OS X 10.4 SDK, and NASM 2.07 or later from
251MacPorts, must be installed.
DRC0dedd1a2010-07-02 09:20:12 +0000252
253
DRC5039d732013-01-21 23:42:12 +000025432-bit Backward-Compatible Build on OS X
255----------------------------------------
DRC0dedd1a2010-07-02 09:20:12 +0000256
257Add
258
DRC5950c5d2012-06-28 23:22:03 +0000259 --host i686-apple-darwin \
260 CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
DRC485cd802010-02-23 23:23:42 +0000261 -mmacosx-version-min=10.4 -O3 -m32' \
DRC68fef832010-02-16 05:29:10 +0000262 LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
263 -mmacosx-version-min=10.4 -m32'
264
265to the configure command line. The OS X 10.4 SDK must be installed.
266
267
26864-bit Library Build on 64-bit Solaris
269--------------------------------------
270
DRCca5e7d12010-02-17 02:25:06 +0000271Add
DRC68fef832010-02-16 05:29:10 +0000272
DRC2e4d0442011-02-08 01:18:37 +0000273 --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
DRC68fef832010-02-16 05:29:10 +0000274
275to the configure command line.
276
277
DRC5039d732013-01-21 23:42:12 +000027832-bit Build on 64-bit FreeBSD
279------------------------------
DRC7bac07b2010-04-10 05:53:35 +0000280
281Add
282
DRC2e4d0442011-02-08 01:18:37 +0000283 --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
284 LDFLAGS='-B/usr/lib32'
DRC7bac07b2010-04-10 05:53:35 +0000285
286to the configure command line. NASM 2.07 or later from FreeBSD ports must be
287installed.
288
289
DRC0559e942012-03-23 03:12:35 +0000290Oracle Solaris Studio
291---------------------
DRCca5e7d12010-02-17 02:25:06 +0000292
293Add
294
DRC2e4d0442011-02-08 01:18:37 +0000295 CC=cc
DRCca5e7d12010-02-17 02:25:06 +0000296
297to the configure command line. libjpeg-turbo will automatically be built with
DRC2e4d0442011-02-08 01:18:37 +0000298the maximum optimization level (-xO5) unless you override CFLAGS.
DRCca5e7d12010-02-17 02:25:06 +0000299
DRC0559e942012-03-23 03:12:35 +0000300To build a 64-bit version of libjpeg-turbo using Oracle Solaris Studio, add
DRCca5e7d12010-02-17 02:25:06 +0000301
DRC2e4d0442011-02-08 01:18:37 +0000302 --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
DRCca5e7d12010-02-17 02:25:06 +0000303
304to the configure command line.
305
DRC8b014d72010-02-18 13:03:41 +0000306
DRC81543312010-10-18 07:23:58 +0000307MinGW Build on Cygwin
308---------------------
309
310Use CMake (see recipes below)
311
312
DRC94755ce2011-10-19 05:13:27 +0000313===========
314ARM Support
315===========
316
317This release of libjpeg-turbo can use ARM NEON SIMD instructions to accelerate
318JPEG compression/decompression by approximately 2-4x on ARMv7 and later
319platforms. If libjpeg-turbo is configured on an ARM Linux platform, then the
320build system will automatically include the NEON SIMD routines, if they are
321supported.
322
323
324Building libjpeg-turbo for iOS
325------------------------------
326
327iOS platforms, such as the iPhone and iPad, also use ARM processors, some of
328which support NEON instructions. Additional steps are required to build
329libjpeg-turbo for these platforms. The steps below assume iOS SDK v4.3. If
330you are using a different SDK version, then you will need to modify the
331examples accordingly.
332
333Additional build requirements:
334
335 gas-preprocessor.pl (https://github.com/yuvi/gas-preprocessor) should be
336 installed in your PATH.
337
338Set the following shell variables for simplicity:
339
DRCa2a2cd62013-02-04 22:29:57 +0000340 Xcode 3.2.x / iOS 4.3 SDK:
DRC94755ce2011-10-19 05:13:27 +0000341 IOS_PLATFORMDIR="/Developer/Platforms/iPhoneOS.platform"
342 IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS4.3.sdk"
343 IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
344
DRCa2a2cd62013-02-04 22:29:57 +0000345 Xcode 4.5.x / iOS 6.0 SDK:
346 IOS_PLATFORMDIR="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform"
347 IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.0.sdk"
348 IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
349
DRC94755ce2011-10-19 05:13:27 +0000350 ARM v6 only (up to and including iPhone 3G):
DRCa2a2cd62013-02-04 22:29:57 +0000351 [NOTE: Requires Xcode 4.4.x or earlier]
DRC94755ce2011-10-19 05:13:27 +0000352 IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
353
DRC5039d732013-01-21 23:42:12 +0000354 ARM v7 only (iPhone 3GS-4S, iPad 1st-3rd Generation):
DRC94755ce2011-10-19 05:13:27 +0000355 IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon"
356
DRCa2a2cd62013-02-04 22:29:57 +0000357 ARM v7s only (iPhone 5, iPad 4th Generation):
358 [NOTE: Requires Xcode 4.5 or later]
359 IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
360
DRC94755ce2011-10-19 05:13:27 +0000361Follow the procedure under "Building libjpeg-turbo" above, adding
362
DRC89c59dd2011-10-27 20:40:21 +0000363 --host arm-apple-darwin10 --enable-static --disable-shared \
DRC94755ce2011-10-19 05:13:27 +0000364 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
368to the configure command line.
369
DRCa2a2cd62013-02-04 22:29:57 +0000370Once built, lipo can be used to combine the ARM v6, v7, and/or v7s variants
371into a universal library.
DRC5039d732013-01-21 23:42:12 +0000372
DRCfde862b2013-02-11 03:38:53 +0000373NOTE: If you are building libjpeg-turbo from the "official" project tarball,
374then it is highly likely that you will need to run 'autoreconf -fiv' in the
375source tree prior to building ARM v7 or v7s iOS binaries using the techniques
376described above. Otherwise, you may get a libtool error such as "unable to
377infer tagged configuration."
378
DRC81543312010-10-18 07:23:58 +0000379
DRC68fef832010-02-16 05:29:10 +0000380*******************************************************************************
DRC81543312010-10-18 07:23:58 +0000381** Building on Windows (Visual C++ or MinGW)
DRC68fef832010-02-16 05:29:10 +0000382*******************************************************************************
383
DRCcc243742010-10-16 09:22:43 +0000384
DRC68fef832010-02-16 05:29:10 +0000385==================
386Build Requirements
387==================
388
DRCcc243742010-10-16 09:22:43 +0000389-- CMake (http://www.cmake.org) v2.6 or later
DRC68fef832010-02-16 05:29:10 +0000390
DRCcc243742010-10-16 09:22:43 +0000391-- Microsoft Visual C++ 2005 or later
DRC68fef832010-02-16 05:29:10 +0000392
DRCcc243742010-10-16 09:22:43 +0000393 If you don't already have Visual C++, then the easiest way to get it is by
394 installing the Windows SDK:
DRC68fef832010-02-16 05:29:10 +0000395
DRCcc243742010-10-16 09:22:43 +0000396 http://msdn.microsoft.com/en-us/windows/bb980924.aspx
397
398 The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
399 everything necessary to build libjpeg-turbo.
400
401 * For 32-bit builds, you can also use Microsoft Visual C++ Express
402 Edition. Visual C++ Express Edition is a free download.
403 * If you intend to build libjpeg-turbo from the command line, then add the
404 appropriate compiler and SDK directories to the INCLUDE, LIB, and PATH
405 environment variables. This is generally accomplished by executing
406 vcvars32.bat or vcvars64.bat and SetEnv.cmd. vcvars32.bat and
407 vcvars64.bat are part of Visual C++ and are located in the same directory
408 as the compiler. SetEnv.cmd is part of the Windows SDK. You can pass
409 optional arguments to SetEnv.cmd to specify a 32-bit or 64-bit build
410 environment.
411
412... OR ...
413
DRC81543312010-10-18 07:23:58 +0000414-- MinGW
DRCcc243742010-10-16 09:22:43 +0000415
416 GCC v4.1 or later recommended for best performance
DRC68fef832010-02-16 05:29:10 +0000417
DRC377add72010-05-17 16:41:12 +0000418-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
419 a 64-bit build)
DRC68fef832010-02-16 05:29:10 +0000420
DRC5039d732013-01-21 23:42:12 +0000421-- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
422 can be downloaded from http://www.java.com.
DRC218c0c12011-02-05 06:01:18 +0000423
DRCcc243742010-10-16 09:22:43 +0000424
425==================
426Out-of-Tree Builds
427==================
428
429Binary objects, libraries, and executables are generated in the same directory
430from which cmake was executed (the "binary directory"), and this directory need
431not necessarily be the same as the libjpeg-turbo source directory. You can
432create multiple independent binary directories, in which different versions of
433libjpeg-turbo can be built from the same source tree using different compilers
434or settings. In the sections below, {build_directory} refers to the binary
435directory, whereas {source_directory} refers to the libjpeg-turbo source
436directory. For in-tree builds, these directories are the same.
437
438
DRC68fef832010-02-16 05:29:10 +0000439======================
440Building libjpeg-turbo
441======================
442
DRC68fef832010-02-16 05:29:10 +0000443
DRCcc243742010-10-16 09:22:43 +0000444Visual C++ (Command Line)
445-------------------------
DRC68fef832010-02-16 05:29:10 +0000446
DRCcc243742010-10-16 09:22:43 +0000447 cd {build_directory}
448 cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
449 nmake
DRC68fef832010-02-16 05:29:10 +0000450
DRCcc243742010-10-16 09:22:43 +0000451This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
452on which version of cl.exe is in the PATH.
DRC8b014d72010-02-18 13:03:41 +0000453
DRCcc243742010-10-16 09:22:43 +0000454The following files will be generated under {build_directory}:
455
456 jpeg-static.lib
DRC5039d732013-01-21 23:42:12 +0000457 Static link library for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000458 sharedlib/jpeg{version}.dll
DRC5039d732013-01-21 23:42:12 +0000459 DLL for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000460 sharedlib/jpeg.lib
DRC5039d732013-01-21 23:42:12 +0000461 Import library for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000462 turbojpeg-static.lib
DRC5039d732013-01-21 23:42:12 +0000463 Static link library for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000464 turbojpeg.dll
DRC5039d732013-01-21 23:42:12 +0000465 DLL for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000466 turbojpeg.lib
DRC5039d732013-01-21 23:42:12 +0000467 Import library for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000468
469{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
DRCf38eee02011-02-18 07:00:38 +0000470v8 emulation is enabled.
DRCcc243742010-10-16 09:22:43 +0000471
472
473Visual C++ (IDE)
474----------------
475
476Choose the appropriate CMake generator option for your version of Visual Studio
477(run "cmake" with no arguments for a list of available generators.) For
478instance:
479
480 cd {build_directory}
481 cmake -G "Visual Studio 9 2008" {source_directory}
482
483You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
484configurations in that project ("Debug", "Release", etc.) to generate a full
485build of libjpeg-turbo.
486
487This will generate the following files under {build_directory}:
488
489 {configuration}/jpeg-static.lib
DRC5039d732013-01-21 23:42:12 +0000490 Static link library for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000491 sharedlib/{configuration}/jpeg{version}.dll
DRC5039d732013-01-21 23:42:12 +0000492 DLL for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000493 sharedlib/{configuration}/jpeg.lib
DRC5039d732013-01-21 23:42:12 +0000494 Import library for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000495 {configuration}/turbojpeg-static.lib
DRC5039d732013-01-21 23:42:12 +0000496 Static link library for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000497 {configuration}/turbojpeg.dll
DRC5039d732013-01-21 23:42:12 +0000498 DLL for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000499 {configuration}/turbojpeg.lib
DRC5039d732013-01-21 23:42:12 +0000500 Import library for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000501
502{configuration} is Debug, Release, RelWithDebInfo, or MinSizeRel, depending on
503the configuration you built in the IDE, and {version} is 62, 7, or 8,
DRCf38eee02011-02-18 07:00:38 +0000504depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
DRCcc243742010-10-16 09:22:43 +0000505
506
507MinGW
508-----
509
510 cd {build_directory}
511 cmake -G "MSYS Makefiles" {source_directory}
512 make
513
514This will generate the following files under {build_directory}
515
516 libjpeg.a
DRC5039d732013-01-21 23:42:12 +0000517 Static link library for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000518 sharedlib/libjpeg-{version}.dll
DRC5039d732013-01-21 23:42:12 +0000519 DLL for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000520 sharedlib/libjpeg.dll.a
DRC5039d732013-01-21 23:42:12 +0000521 Import library for the libjpeg API
DRCcc243742010-10-16 09:22:43 +0000522 libturbojpeg.a
DRC5039d732013-01-21 23:42:12 +0000523 Static link library for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000524 libturbojpeg.dll
DRC5039d732013-01-21 23:42:12 +0000525 DLL for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000526 libturbojpeg.dll.a
DRC5039d732013-01-21 23:42:12 +0000527 Import library for the TurboJPEG API
DRCcc243742010-10-16 09:22:43 +0000528
529{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
DRCf38eee02011-02-18 07:00:38 +0000530v8 emulation is enabled.
DRCcc243742010-10-16 09:22:43 +0000531
532
DRCcc243742010-10-16 09:22:43 +0000533Debug Build
534-----------
535
536Add "-DCMAKE_BUILD_TYPE=Debug" to the cmake command line. Or, if building with
537NMake, remove "-DCMAKE_BUILD_TYPE=Release" (Debug builds are the default with
538NMake.)
539
540
DRC30913542012-01-27 09:53:33 +0000541libjpeg v7 or v8 API/ABI Emulation
542-----------------------------------
DRCcc243742010-10-16 09:22:43 +0000543
544Add "-DWITH_JPEG7=1" to the cmake command line to build a version of
DRC30913542012-01-27 09:53:33 +0000545libjpeg-turbo that is API/ABI-compatible with libjpeg v7. Add "-DWITH_JPEG8=1"
546to the cmake command to build a version of libjpeg-turbo that is
547API/ABI-compatible with libjpeg v8. See README-turbo.txt for more information
548on libjpeg v7 and v8 emulation.
DRCcc243742010-10-16 09:22:43 +0000549
550
DRC5039d732013-01-21 23:42:12 +0000551In-Memory Source/Destination Managers
552-------------------------------------
553
554When using libjpeg v6b or v7 API/ABI emulation, add -DWITH_MEM_SRCDST=0 to the
555CMake command line to build a version of libjpeg-turbo that lacks the
556jpeg_mem_src() and jpeg_mem_dest() functions. These functions were not part of
557the original libjpeg v6b and v7 APIs, so removing them ensures strict
558conformance with those APIs. See README-turbo.txt for more information.
559
560
DRC245cfdf2010-11-23 17:11:06 +0000561Arithmetic Coding Support
562-------------------------
563
564Since the patent on arithmetic coding has expired, this functionality has been
565included in this release of libjpeg-turbo. libjpeg-turbo's implementation is
DRCf38eee02011-02-18 07:00:38 +0000566based on the implementation in libjpeg v8, but it works when emulating libjpeg
DRC245cfdf2010-11-23 17:11:06 +0000567v7 or v6b as well. The default is to enable both arithmetic encoding and
568decoding, but those who have philosophical objections to arithmetic coding can
569add "-DWITH_ARITH_ENC=0" or "-DWITH_ARITH_DEC=0" to the cmake command line to
570disable encoding or decoding (respectively.)
571
572
DRC5039d732013-01-21 23:42:12 +0000573TurboJPEG Java Wrapper
574----------------------
DRC279bd342011-04-02 05:17:12 +0000575Add "-DWITH_JAVA=1" to the cmake command line to incorporate an optional Java
DRC5039d732013-01-21 23:42:12 +0000576Native Interface wrapper into the TurboJPEG shared library and build the Java
577front-end classes to support it. This allows the TurboJPEG shared library to
578be used directly from Java applications. See java/README for more details.
DRC218c0c12011-02-05 06:01:18 +0000579
DRCdb425062011-04-03 06:10:18 +0000580If you are using CMake 2.8, you can set the Java_JAVAC_EXECUTABLE,
581Java_JAVA_EXECUTABLE, and Java_JAR_EXECUTABLE CMake variables to specify
582alternate commands or locations for javac, jar, and java (respectively.) If
583you are using CMake 2.6, set JAVA_COMPILE, JAVA_RUNTIME, and JAVA_ARCHIVE
584instead. You can also set the JAVACFLAGS CMake variable to specify arguments
585that should be passed to the Java compiler when building the front-end classes.
586
DRC218c0c12011-02-05 06:01:18 +0000587
DRC26658432010-10-16 22:04:29 +0000588========================
589Installing libjpeg-turbo
590========================
591
592You can use the build system to install libjpeg-turbo into a directory of your
593choosing (as opposed to creating an installer.) To do this, add:
594
595 -DCMAKE_INSTALL_PREFIX={install_directory}
596
597to the cmake command line.
598
599For example,
600
DRC81543312010-10-18 07:23:58 +0000601 cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
DRC26658432010-10-16 22:04:29 +0000602 -DCMAKE_INSTALL_PREFIX=c:\libjpeg-turbo {source_directory}
603 nmake install
604
605will install the header files in c:\libjpeg-turbo\include, the library files
606in c:\libjpeg-turbo\lib, the DLL's in c:\libjpeg-turbo\bin, and the
607documentation in c:\libjpeg-turbo\doc.
608
609
DRCcc243742010-10-16 09:22:43 +0000610=============
611Build Recipes
612=============
613
614
DRC1c73ce82010-10-16 21:02:54 +000061564-bit MinGW Build on Cygwin
616----------------------------
617
618 cd {build_directory}
DRC2e4d0442011-02-08 01:18:37 +0000619 CC=/usr/bin/x86_64-w64-mingw32-gcc \
DRC68bf3f22010-10-18 07:56:14 +0000620 cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
621 -DCMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar \
DRC1c73ce82010-10-16 21:02:54 +0000622 -DCMAKE_RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib {source_directory}
623 make
624
625This produces a 64-bit build of libjpeg-turbo that does not depend on
626cygwin1.dll or other Cygwin DLL's. The mingw64-x86_64-gcc-core and
627mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
628
629
63032-bit MinGW Build on Cygwin
631----------------------------
632
633 cd {build_directory}
DRC2e4d0442011-02-08 01:18:37 +0000634 CC=/usr/bin/i686-w64-mingw32-gcc \
DRC68bf3f22010-10-18 07:56:14 +0000635 cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
636 -DDCMAKE_AR=/usr/bin/i686-w64-mingw32-ar \
DRC1c73ce82010-10-16 21:02:54 +0000637 -DCMAKE_RANLIB=/usr/bin/i686-w64-mingw32-ranlib {source_directory}
638 make
639
640This produces a 32-bit build of libjpeg-turbo that does not depend on
641cygwin1.dll or other Cygwin DLL's. The mingw64-i686-gcc-core and
642mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
643
644
645MinGW-w64 Build on Windows
646--------------------------
647
648This produces a 64-bit build of libjpeg-turbo using the "native" MinGW-w64
649toolchain (which is faster than the Cygwin version):
650
651 cd {build_directory}
652 CC={mingw-w64_binary_path}/x86_64-w64-mingw32-gcc \
DRC81543312010-10-18 07:23:58 +0000653 cmake -G "MSYS Makefiles" \
DRC1c73ce82010-10-16 21:02:54 +0000654 -DCMAKE_AR={mingw-w64_binary_path}/x86_64-w64-mingw32-ar \
655 -DCMAKE_RANLIB={mingw-w64_binary_path}/x86_64-w64-mingw32-ranlib \
656 {source_directory}
657 make
658
659
DRCcc243742010-10-16 09:22:43 +0000660MinGW Build on Linux
661--------------------
662
663 cd {build_directory}
664 CC={mingw_binary_path}/i386-mingw32-gcc \
DRC68bf3f22010-10-18 07:56:14 +0000665 cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
666 -DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
DRCcc243742010-10-16 09:22:43 +0000667 -DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
DRC68bf3f22010-10-18 07:56:14 +0000668 {source_directory}
DRCcc243742010-10-16 09:22:43 +0000669 make
DRC8b014d72010-02-18 13:03:41 +0000670
DRC68fef832010-02-16 05:29:10 +0000671
672*******************************************************************************
673** Creating Release Packages
674*******************************************************************************
675
676The following commands can be used to create various types of release packages:
677
DRCcc243742010-10-16 09:22:43 +0000678
679Unix
680----
681
DRC68fef832010-02-16 05:29:10 +0000682make rpm
683
DRCcc243742010-10-16 09:22:43 +0000684 Create Red Hat-style binary RPM package. Requires RPM v4 or later.
DRC68fef832010-02-16 05:29:10 +0000685
686make srpm
687
688 This runs 'make dist' to create a pristine source tarball, then creates a
DRCcc243742010-10-16 09:22:43 +0000689 Red Hat-style source RPM package from the tarball. Requires RPM v4 or later.
DRC68fef832010-02-16 05:29:10 +0000690
691make deb
692
693 Create Debian-style binary package. Requires dpkg.
694
695make dmg
696
697 Create Macintosh package/disk image. This requires the PackageMaker
698 application, which must be installed in /Developer/Applications/Utilities.
DRC7ed0aeb2013-02-24 20:39:30 +0000699 Note that PackageMaker is not included in recent releases of Xcode, but it
700 can be obtained by downloading the "Auxiliary Tools for Xcode" package from
701 http://developer.apple.com/downloads.
DRC68fef832010-02-16 05:29:10 +0000702
DRC9ef93db2010-10-18 08:24:42 +0000703make udmg [BUILDDIR32={32-bit build directory}]
DRC68fef832010-02-16 05:29:10 +0000704
DRC20b734e2012-02-10 01:30:37 +0000705 On 64-bit OS X systems, this creates a Macintosh package and disk image that
706 contains universal i386/x86-64 binaries. You should first configure a 32-bit
707 out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree
708 build, then run 'make udmg' from the 64-bit build directory. The build
709 system will look for the 32-bit build under {source_directory}/osxx86 by
710 default, but you can override this by setting the BUILDDIR32 variable on the
711 make command line as shown above.
712
713make iosdmg [BUILDDIR32={32-bit build directory}] \
714 [BUILDDIRARMV6={ARM v6 build directory}] \
715 [BUILDDIRARMV7={ARM v7 build directory}] \
DRCa2a2cd62013-02-04 22:29:57 +0000716 [BUILDDIRARMV7S={ARM v7s build directory}]
DRC20b734e2012-02-10 01:30:37 +0000717
718 On OS X systems, this creates a Macintosh package and disk image in which the
719 libjpeg-turbo static libraries contain ARM architectures necessary to build
720 iOS applications. If building on an x86-64 system, the binaries will also
721 contain the i386 architecture, as with 'make udmg' above. You should first
DRCa2a2cd62013-02-04 22:29:57 +0000722 configure ARM v6, ARM v7, and/or ARM v7s out-of-tree builds of libjpeg-turbo
723 (see "Building libjpeg-turbo for iOS" above.) If you are building an x86-64
DRC20b734e2012-02-10 01:30:37 +0000724 version of libjpeg-turbo, you should configure a 32-bit out-of-tree build as
725 well. Next, build libjpeg-turbo as you would normally, using an out-of-tree
726 build. When it is built, run 'make iosdmg' from the build directory. The
727 build system will look for the ARM v6 build under {source_directory}/iosarmv6
728 by default, the ARM v7 build under {source_directory}/iosarmv7 by default,
DRCa2a2cd62013-02-04 22:29:57 +0000729 the ARM v7s build under {source_directory}/iosarmv7s by default, and (if
730 applicable) the 32-bit build under {source_directory}/osxx86 by default, but
731 you can override this by setting the BUILDDIR32, BUILDDIRARMV6,
732 BUILDDIRARMV7, and/or BUILDDIRARMV7S variables on the make command line as
733 shown above.
DRC68fef832010-02-16 05:29:10 +0000734
DRC81543312010-10-18 07:23:58 +0000735make cygwinpkg
736
737 Build a Cygwin binary package.
738
DRC0a1f68e2010-02-24 07:24:26 +0000739
DRCcc243742010-10-16 09:22:43 +0000740Windows
741-------
DRC0a1f68e2010-02-24 07:24:26 +0000742
DRCcc243742010-10-16 09:22:43 +0000743If using NMake:
DRC68fef832010-02-16 05:29:10 +0000744
DRCcc243742010-10-16 09:22:43 +0000745 cd {build_directory}
746 nmake installer
747
DRC81543312010-10-18 07:23:58 +0000748If using MinGW:
DRCcc243742010-10-16 09:22:43 +0000749
750 cd {build_directory}
751 make installer
752
753If using the Visual Studio IDE, build the "installer" project.
754
755The installer package (libjpeg-turbo[-gcc][64].exe) will be located under
756{build_directory}. If building using the Visual Studio IDE, then the installer
757package will be located in a subdirectory with the same name as the
758configuration you built (such as {build_directory}\Debug\ or
759{build_directory}\Release\).
760
761Building a Windows installer requires the Nullsoft Install System
762(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH.
DRC9cd4e4b2012-01-31 07:56:44 +0000763
764
765*******************************************************************************
766** Regression testing
767*******************************************************************************
768
769The most common way to test libjpeg-turbo is by invoking 'make test' on
770Unix/Linux platforms or 'ctest' on Windows platforms, once the build has
771completed. This runs a series of tests to ensure that mathematical
772compatibility has been maintained between libjpeg-turbo and libjpeg v6b. This
773also invokes the TurboJPEG unit tests, which ensure that the colorspace
774extensions, YUV encoding, decompression scaling, and other features of the
775TurboJPEG C and Java APIs are working properly (and, by extension, that the
776equivalent features of the underlying libjpeg API are also working.)
777
778Invoking 'make testclean' or 'nmake testclean' (if using NMake) or building
779the 'testclean' target (if using the Visual Studio IDE) will clean up the
780output images generated by 'make test'.
781
DRC5039d732013-01-21 23:42:12 +0000782On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java
DRC9cd4e4b2012-01-31 07:56:44 +0000783wrappers can be run by invoking 'make tjtest'. These extended TurboJPEG tests
784essentially iterate through all of the available features of the TurboJPEG APIs
785that are not covered by the TurboJPEG unit tests (this includes the lossless
786transform options) and compare the images generated by each feature to images
787generated using the equivalent feature in the libjpeg API. The extended
788TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
DRC5039d732013-01-21 23:42:12 +0000789not in the underlying libjpeg API library.