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