xref: /aosp_15_r20/external/webp/doc/building.md (revision b2055c353e87c8814eb2b6b1b11112a1562253bd)
1# Building
2
3## Windows build
4
5By running:
6
7```batch
8nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
9```
10
11the directory `output\release-static\(x64|x86)\bin` will contain the tools
12cwebp.exe and dwebp.exe. The directory `output\release-static\(x64|x86)\lib`
13will contain the libwebp static library. The target architecture (x86/x64) is
14detected by Makefile.vc from the Visual Studio compiler (cl.exe) available in
15the system path.
16
17## Unix build using makefile.unix
18
19On platforms with GNU tools installed (gcc and make), running
20
21```shell
22make -f makefile.unix
23```
24
25will build the binaries examples/cwebp and examples/dwebp, along with the static
26library src/libwebp.a. No system-wide installation is supplied, as this is a
27simple alternative to the full installation system based on the autoconf tools
28(see below). Please refer to makefile.unix for additional details and
29customizations.
30
31## Using autoconf tools
32
33Prerequisites: a compiler (e.g., gcc), make, autoconf, automake, libtool.
34
35On a Debian-like system the following should install everything you need for a
36minimal build:
37
38```shell
39$ sudo apt-get install gcc make autoconf automake libtool
40```
41
42When building from git sources, you will need to run autogen.sh to generate the
43configure script.
44
45```shell
46./configure
47make
48make install
49```
50
51should be all you need to have the following files
52
53```
54/usr/local/include/webp/decode.h
55/usr/local/include/webp/encode.h
56/usr/local/include/webp/types.h
57/usr/local/lib/libwebp.*
58/usr/local/bin/cwebp
59/usr/local/bin/dwebp
60```
61
62installed.
63
64Note: A decode-only library, libwebpdecoder, is available using the
65`--enable-libwebpdecoder` flag. The encode library is built separately and can
66be installed independently using a minor modification in the corresponding
67Makefile.am configure files (see comments there). See `./configure --help` for
68more options.
69
70## Building for MIPS Linux
71
72MIPS Linux toolchain stable available releases can be found at:
73https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/
74
75```shell
76# Add toolchain to PATH
77export PATH=$PATH:/path/to/toolchain/bin
78
79# 32-bit build for mips32r5 (p5600)
80HOST=mips-mti-linux-gnu
81MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64 \
82  -msched-weight -mload-store-pairs -fPIE"
83MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"
84
85# 64-bit build for mips64r6 (i6400)
86HOST=mips-img-linux-gnu
87MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64 \
88  -msched-weight -mload-store-pairs -fPIE"
89MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"
90
91./configure --host=${HOST} --build=`config.guess` \
92  CC="${HOST}-gcc -EL" \
93  CFLAGS="$MIPS_CFLAGS" \
94  LDFLAGS="$MIPS_LDFLAGS"
95make
96make install
97```
98
99## Building libwebp - Using vcpkg
100
101You can download and install libwebp using the
102[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
103
104```shell
105git clone https://github.com/Microsoft/vcpkg.git
106cd vcpkg
107./bootstrap-vcpkg.sh
108./vcpkg integrate install
109./vcpkg install libwebp
110```
111
112The libwebp port in vcpkg is kept up to date by Microsoft team members and
113community contributors. If the version is out of date, please
114[create an issue or pull request](https://github.com/Microsoft/vcpkg) on the
115vcpkg repository.
116
117## CMake
118
119With CMake, you can compile libwebp, cwebp, dwebp, gif2webp, img2webp, webpinfo
120and the JS bindings.
121
122Prerequisites: a compiler (e.g., gcc with autotools) and CMake.
123
124On a Debian-like system the following should install everything you need for a
125minimal build:
126
127```shell
128$ sudo apt-get install build-essential cmake
129```
130
131When building from git sources, you will need to run cmake to generate the
132makefiles.
133
134```shell
135mkdir build && cd build && cmake ../
136make
137make install
138```
139
140If you also want any of the executables, you will need to enable them through
141CMake, e.g.:
142
143```shell
144cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../
145```
146
147or through your favorite interface (like ccmake or cmake-qt-gui).
148
149Use option `-DWEBP_UNICODE=ON` for Unicode support on Windows (with chcp 65001).
150
151Finally, once installed, you can also use WebP in your CMake project by doing:
152
153```cmake
154find_package(WebP)
155```
156
157which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES.
158
159## Gradle
160
161The support for Gradle is minimal: it only helps you compile libwebp, cwebp and
162dwebp and webpmux_example.
163
164Prerequisites: a compiler (e.g., gcc with autotools) and gradle.
165
166On a Debian-like system the following should install everything you need for a
167minimal build:
168
169```shell
170$ sudo apt-get install build-essential gradle
171```
172
173When building from git sources, you will need to run the Gradle wrapper with the
174appropriate target, e.g. :
175
176```shell
177./gradlew buildAllExecutables
178```
179
180## SWIG bindings
181
182To generate language bindings from swig/libwebp.swig at least swig-1.3
183(http://www.swig.org) is required.
184
185Currently the following functions are mapped:
186
187Decode:
188
189```
190WebPGetDecoderVersion
191WebPGetInfo
192WebPDecodeRGBA
193WebPDecodeARGB
194WebPDecodeBGRA
195WebPDecodeBGR
196WebPDecodeRGB
197```
198
199Encode:
200
201```
202WebPGetEncoderVersion
203WebPEncodeRGBA
204WebPEncodeBGRA
205WebPEncodeRGB
206WebPEncodeBGR
207WebPEncodeLosslessRGBA
208WebPEncodeLosslessBGRA
209WebPEncodeLosslessRGB
210WebPEncodeLosslessBGR
211```
212
213See also the [swig documentation](../swig/README.md) for more detailed build
214instructions and usage examples.
215
216### Java bindings
217
218To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent) is
219necessary for enum support. The output is intended to be a shared object / DLL
220that can be loaded via `System.loadLibrary("webp_jni")`.
221
222### Python bindings
223
224To build the swig-generated Python extension code at least Python 2.6 is
225required. Python < 2.6 may build with some minor changes to libwebp.swig or the
226generated code, but is untested.
227
228## Javascript decoder
229
230Libwebp can be compiled into a JavaScript decoder using Emscripten and CMake.
231See the [corresponding documentation](../README.md)
232