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