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## CMake 100 101With CMake, you can compile libwebp, cwebp, dwebp, gif2webp, img2webp, webpinfo 102and the JS bindings. 103 104Prerequisites: a compiler (e.g., gcc with autotools) and CMake. 105 106On a Debian-like system the following should install everything you need for a 107minimal build: 108 109```shell 110$ sudo apt-get install build-essential cmake 111``` 112 113When building from git sources, you will need to run cmake to generate the 114makefiles. 115 116```shell 117mkdir build && cd build && cmake ../ 118make 119make install 120``` 121 122If you also want any of the executables, you will need to enable them through 123CMake, e.g.: 124 125```shell 126cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../ 127``` 128 129or through your favorite interface (like ccmake or cmake-qt-gui). 130 131Use option `-DWEBP_UNICODE=ON` for Unicode support on Windows (with chcp 65001). 132 133Finally, once installed, you can also use WebP in your CMake project by doing: 134 135```cmake 136find_package(WebP) 137``` 138 139which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES. 140 141## Gradle 142 143The support for Gradle is minimal: it only helps you compile libwebp, cwebp and 144dwebp and webpmux_example. 145 146Prerequisites: a compiler (e.g., gcc with autotools) and gradle. 147 148On a Debian-like system the following should install everything you need for a 149minimal build: 150 151```shell 152$ sudo apt-get install build-essential gradle 153``` 154 155When building from git sources, you will need to run the Gradle wrapper with the 156appropriate target, e.g. : 157 158```shell 159./gradlew buildAllExecutables 160``` 161 162## SWIG bindings 163 164To generate language bindings from swig/libwebp.swig at least swig-1.3 165(http://www.swig.org) is required. 166 167Currently the following functions are mapped: 168 169Decode: 170 171``` 172WebPGetDecoderVersion 173WebPGetInfo 174WebPDecodeRGBA 175WebPDecodeARGB 176WebPDecodeBGRA 177WebPDecodeBGR 178WebPDecodeRGB 179``` 180 181Encode: 182 183``` 184WebPGetEncoderVersion 185WebPEncodeRGBA 186WebPEncodeBGRA 187WebPEncodeRGB 188WebPEncodeBGR 189WebPEncodeLosslessRGBA 190WebPEncodeLosslessBGRA 191WebPEncodeLosslessRGB 192WebPEncodeLosslessBGR 193``` 194 195See also the [swig documentation](../swig/README.md) for more detailed build 196instructions and usage examples. 197 198### Java bindings 199 200To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent) is 201necessary for enum support. The output is intended to be a shared object / DLL 202that can be loaded via `System.loadLibrary("webp_jni")`. 203 204### Python bindings 205 206To build the swig-generated Python extension code at least Python 2.6 is 207required. Python < 2.6 may build with some minor changes to libwebp.swig or the 208generated code, but is untested. 209 210## Javascript decoder 211 212Libwebp can be compiled into a JavaScript decoder using Emscripten and CMake. 213See the [corresponding documentation](../README.md) 214