Building on Windows

Compiler

iipsrv can be built from source on Windows using Microsoft Visual Studio. The community edition is free to download and is sufficient for building iipsrv.

iipsrv is written in C++, so make sure you install the following components:

  • Visual Studio C++ core features
  • Windows 10 SDK
  • Windows Universal CRT SDK
  • Windows Universal C Runtime

Dependencies

There are a number of dependencies required by iipsrv:

  • libtiff
  • libjpeg
  • zlib
  • libfcgi
  • OpenJPEG (JPEG2000 support: optional)
  • libpng (PNG output support: optional)
  • libwebp (WebP output support: optional)
  • libavif (AVIF output support: optional)
  • libmemcached (Memcached support: optional)

These can be built individually or preferably you can manage and automate this using a package manager such as vcpkg.

To use vcpkg, follow the installation instructions to install vcpkg into a suitable folder (for example: C:\dev\vcpkg). Then simply install the dependencies for your target platform from the command line (set the triplet to x86-windows or x64-windows):

.\vcpkg.exe install tiff openjpeg fastcgi libpng libwebp libavif[aom] --triplet x64-windows

zlib, libjpeg-turbo and liblzma are installed automatically as part of libtiff.

In order to make these automatically available to Visual Studio, integrate vcpkg using the command:

.\vcpkg.exe integrate install

libmemcached

libmemcached, however, is not currently available from vcpkg, so to enable Memcached support, download libmemcached-awesome, a fork of the original libmemcached. Pre-compiled 64 bit binary versions are available which can be downloaded and installed to, for example, the folder C:\dev\.

If you wish to build from source, this can be accomplished using cmake. Make sure cmake is installed as well as bison and flex (a Windows version is available here).

To compile, first navigate using the console into the libmemcached folder and configure cmake where -B is the folder into which the build will occur and –install-prefix is the folder into which the final installation will occur:

cmake -B build --install-prefix C:\dev\

This configures cmake to build 64 bit binaries by default. For 32 bit, add -A Win32 to the above command.

Now build the Release version and install into the folder defined above:

cmake --build build --config Release --target install

This should create the necessary include, lib and bin directories in C:\dev\

Building iipsrv

Now that we have built and installed our dependencies, we can now build iipsrv itself. First download the source code from the latest release or use a Windows git client to check out the latest development version directly from Github. Download this into, for example, the folder C:\dev\src\

git clone https://github.com/ruven/iipsrv.git

Open Visual Studio and choose open an existing solution. Navigate to the windows sub-directory within the iipsrv folder (iipsrv\windows). There are builds for Visual Studio 2010, 2017 and 2022. Open the folder corresponding to your version of Visual Studio and open the .sln solution file within.

The vcpkg dependencies should be loaded automatically. Open Project properties -> vcpkg and make sure it is activated.

If you have downloaded or built the libmemcached dependencies as described above, copy the includes to the iipsrv\windows\dependencies\include folder. For the libmemcached libraries, create a folder libs within the iipsrv Visual Studio folder, then within that another folder depending on your target platform: x86 or x64. Now copy the .lib files to this newly created folder (for example iipsrv\windows\Visual Studio 2022\libs\x64\). These paths are included automatically within the Visual Studio solution.

Alternatively, add the libmemcached installation include and library paths to the project configuration:

  • Project properties -> C/C++ -> General -> AdditionalIncludeDirectories
  • Project properties -> VC++ Directories -> Library Directories

Memcached, PNG, WebP, AVIF and OpenJPEG support is activated by default in the Visual Studio solution. To disable, remove the appropriate pre-processor directive: HAVE_MEMCACHED, HAVE_PNG, HAVE_WEBP, HAVE_AVIF or HAVE_OPENJPEG.

Now build the solution. There are 32 bit (Win32) and 64 bit (x64) target platforms available as either Release or Debug. Make sure these match the choice of platform made for vcpkg. For the 64 bit Release version, the iipsrv executable will be found in iipsrv\windows\Visual Studio XX\Release\x64\iipsrv.fcgi and for 32 bit in Win32\iipsrv.fcgi.

Command Line

To build on the command line, rather than through the Visual Studio graphical interface, open the developer command prompt or developer powershell, change directory to iipsrv\windows\Visual Studio 2022\ and run the following command (change the Platform parameter to win32 for a 32 bit build):

msbuild.exe .\iipsrv-MSVC2022.sln /property:Configuration=Release /property:Platform=x64

Installing iipsrv

To use the iipsrv.fcgi binary with Apache or any other web server, you will need to copy the iipsrv.fcgi executable to an FCGI runtime folder, for example in C:\dev\fcgi-bin\. To work, you will also need to copy the associated DLLs from the vcpkg dependencies and from libmemcached. You can find the vcpkg DLLs in the vcpkg\install\<platform>\bin folder and if using libmemcached, in C:/dev/bin. These should include the following:

  • aom.dll
  • avif.dll
  • fcgi-0.dll
  • jpeg62.dll
  • liblzma.dll
  • libpng16.dll
  • libsharpyuv.dll
  • libwebp.dll
  • libwebpmux.dll
  • libyuv.dll
  • openjp2.dll
  • tiff.dll
  • zlib1.dll

For libmemcached you will additionally need:

  • libhashkit.dll
  • libmemcached.dll
  • libmemcachedprotocol.dll
  • libmemcachedutil.dll

Running iipsrv

Command Line

It’s possible to run the iipsrv executable directly on the command line. First navigate using your console to the FCGI runtime folder and set a couple of environment variables for iipsrv before starting iipsrv itself:

$env:LOGFILE="C:\dev\iipsrv.log"
$env:VERBOSITY=5
.\iipsrv.fcgi --bind "localhost:9000"

This should start an instance of iipsrv and output logging information to C:\dev\iipsrv.log. Use Control-C to stop the process and take a look inside the log file to make sure it’s working. Note that it’s possible that you may have to rename iipsrv.fcgi to iipsrv.exe to allow you to run the executable.

Apache

To run iipsrv with the Apache web server, download Windows binaries from Apache Lounge or Apache Haus. You will need to download Apache itself as well as mod_fcgid. Follow the supplied installation instructions.

To configure iipsrv, for example, with Apache Haus, open the httpd-fcgid.conf file within the conf\extra sub-folder and replace the contents with the following:

<IfModule fcgid_module>

ScriptAlias /fcgi-bin/ "/dev/fcgi-bin/"

<Directory "/dev/fcgi-bin/">
  AllowOverride None
  Options None
  Require all granted
  AddHandler fcgid-script .fcgi
</Directory>

# Set our environment variables for iipsrv
FcgidInitialEnv VERBOSITY "5"
FcgidInitialEnv LOGFILE "C:\dev\iipsrv.log"

FcgidIdleTimeout 0
FcgidMaxProcessesPerClass 1

</IfModule>

For more details on configuration, see the full server documentation.

Testing

Now download a test image and place in C:\images\

Finally open your web browser and open the URL (replace “image.tif” with the name of your image)

http://localhost/fcgi-bin/iipsrv.fcgi?FIF=/images/image.tif&WID=500&CVT=JPEG

This should display a JPEG image with a width of 500px. If not, follow the troubleshooting guide.

 

[Thanks: vcpkg build instructions based on this guide]