# Compiling the Utilities

If the [precompiled utilities](https://developers.google.com/speed/webp/docs/precompiled) don't suit your
needs, you can build the WebP utilities yourself.

## Compiling on Windows with Visual C++

1. Download `libwebp-1.6.0.tar.gz` from the [downloads list](https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html)
   and extract its contents.

2. From the `libwebp-1.6.0` directory, run:

       nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output

   To see additional options, run:

       nmake /f Makefile.vc

3. The directory `output\release-static\x86\bin` or
   `output\release-static\x64\bin` will contain the tools `cwebp.exe` and
   `dwebp.exe` depending on the platform being targeted. The directory
   `output\release-static\(x86|x64)\lib` will contain the `libwebp` static
   library.

## Compiling on Unix-like Platforms

### Preparing the Platform

#### Linux

1. Install the `libjpeg`, `libpng`, `libtiff` and `libgif` packages, needed to
   convert between JPEG, PNG, TIFF, GIF and WebP image formats.

   Package management varies by Linux distribution. On Ubuntu and Debian, the
   following command will install the needed packages:

       sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev

2. Complete the installation ([see below](https://developers.google.com/speed/webp/docs/compiling#building)).

#### macOS

MacPorts is a convenient way to satisfy dependencies. If you already have
MacPorts installed, go directly to Step 3. Otherwise, follow these steps:

1. Download MacPorts for your macOS version from the MacPorts
   [downloads site](https://distfiles.macports.org/MacPorts). MacPorts requires
   the installation of
   [Xcode](https://developer.apple.com/xcode/).

2. Install MacPorts following the MacPorts
   [directions](https://guide.macports.org/).

3. Update MacPorts:

       sudo port selfupdate

4. Install the JPEG, PNG, TIFF and GIF dependencies:

       sudo port install jpeg libpng tiff giflib

5. Complete the installation ([see below](https://developers.google.com/speed/webp/docs/compiling#building)).

#### Cygwin

1. Download setup.exe from the [Cygwin web page](https://www.cygwin.com).

2. Run setup.exe and proceed through the installation.

3. At the **Select Packages** screen, add to the pre-selected packages the
   following:

   - `libjpeg-devel`, `libpng-devel`, `libtiff-devel` and `libgif-devel`

   - `gcc`, `make` and `automake` (for building packages)

4. Complete the installation ([see below](https://developers.google.com/speed/webp/docs/compiling#building)).

### Building

1. Download `libwebp-1.6.0.tar.gz` from the
   [downloads list](https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html).

2. Untar or unzip the package. This creates a directory named `libwebp-1.6.0/`:

       tar xvzf libwebp-1.6.0.tar.gz

3. Build WebP encoder `cwebp` and decoder `dwebp`:

   Go to the directory where `libwebp-1.6.0/` was extracted to
   and run the following commands:

       cd libwebp-1.6.0
       ./configure
       make
       sudo make install

   This builds and installs the `cwebp` and `dwebp` command line tools, along
   with the `libwebp` libraries (dynamic and static).

   These tools are usually installed under `/usr/local/bin/` by default. The
   local versions are built under the `examples/` directory.

   The library will usually be installed under the `/usr/local/lib/` directory.
   To avoid run-time errors, make sure that your `LD_LIBRARY_PATH` environment
   variable includes this location. The C headers are typically installed under
   `/usr/local/include/webp`.

   To see additional options, run:

       ./configure --help

## What Next?

Go to [Using WebP](https://developers.google.com/speed/webp/docs/using) for instructions on how to start
converting your images.