AI-generated Key Takeaways
-
This page provides instructions for building WebP utilities (
cwebpanddwebp) from source code if precompiled options are unsuitable. -
Building on Windows involves using Visual C++ with specific commands to compile the utilities and library.
-
For Unix-like platforms (Linux, macOS, Cygwin), instructions cover installing necessary dependencies before building the WebP tools.
-
The building process on Unix-like systems involves downloading the source code, configuring, compiling, and installing the utilities and libraries.
-
After building the utilities, users can proceed to the "Using WebP" page for image conversion instructions.
If the precompiled utilities don't suit your needs, you can build the WebP utilities yourself.
Compiling on Windows with Visual C++
Download
libwebp-1.6.0.tar.gzfrom the downloads list and extract its contents.From the
libwebp-1.6.0directory, run:nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=outputTo see additional options, run:
nmake /f Makefile.vcThe directory
output\release-static\x86\binoroutput\release-static\x64\binwill contain the toolscwebp.exeanddwebp.exedepending on the platform being targeted. The directoryoutput\release-static\(x86|x64)\libwill contain thelibwebpstatic library.
Compiling on Unix-like Platforms
Preparing the Platform
Linux
Install the
libjpeg,libpng,libtiffandlibgifpackages, 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-devComplete the installation (see below).
macOS
MacPorts is a convenient way to satisfy dependencies. If you already have MacPorts installed, go directly to Step 3. Otherwise, follow these steps:
Download MacPorts for your macOS version from the MacPorts downloads site. MacPorts requires the installation of Xcode.
Install MacPorts following the MacPorts directions.
Update MacPorts:
sudo port selfupdateInstall the JPEG, PNG, TIFF and GIF dependencies:
sudo port install jpeg libpng tiff giflibComplete the installation (see below).
Cygwin
Download setup.exe from the Cygwin web page.
Run setup.exe and proceed through the installation.
At the Select Packages screen, add to the pre-selected packages the following:
libjpeg-devel,libpng-devel,libtiff-develandlibgif-develgcc,makeandautomake(for building packages)
Complete the installation (see below).
Building
Download
libwebp-1.6.0.tar.gzfrom the downloads list.Untar or unzip the package. This creates a directory named
libwebp-1.6.0/:tar xvzf libwebp-1.6.0.tar.gzBuild WebP encoder
cwebpand decoderdwebp: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 installThis builds and installs the
cwebpanddwebpcommand line tools, along with thelibwebplibraries (dynamic and static).These tools are usually installed under
/usr/local/bin/by default. The local versions are built under theexamples/directory.The library will usually be installed under the
/usr/local/lib/directory. To avoid run-time errors, make sure that yourLD_LIBRARY_PATHenvironment 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 for instructions on how to start converting your images.