Building TagLib on Windows

In my hobby project MusicCollection I use TagLib to read tags from audio files. The repository contains an INSTALL file which attempts to detail the steps necessary to build the project both on Linux and on Windows. Building TagLib and using it in a CMake based project is absolutely trivial on Linux. On Windows a bit less so.

Lukáš Lalinský of TagLib and MusicBrainz Picard fame wrote a blog detailing the steps that were necessary to build TagLib on Windows. These steps certainly helped a lot, but were not complete for today. Here is what I needed to do.

The current version of zlib is 1.2.8, the current version of TagLib is 1.9.1. I build a 32 bit version on Windows 7 with Microsoft Visual Studio 2010 or 2012. An answer on was very helpful.

  1. Download the sources for both packages at here and here. (But do check if newer ones are released.)
  2. Unpack and unzip and rename them in the same directory, i.e. e:\workspace\lib. I use 7-Zip on Windows which handles everything I ever come across. Now I have this structure:
  3. Start a “Developer Command Prompt for VS2010” (or VS2012) and navigate to the zlib directory. In my case:

> e:
> cd \workspace\zlib-1.2.8

  1. Build zlib, by first having CMake create a Visual Studio solution file, then building this solution with Visual Studio:

> mkdir build && cd build
> cmake .. -G"Visual Studio 11" -DCMAKE_INSTALL_PREFIX="e:\workspace\lib\installed"
> msbuild /P:Configuration=Debug INSTALL.vcxproj
> msbuild /P:Configuration=Release INSTALL.vcxproj

The -G”Visual Studio 11″ part instructs CMake to generate a Visual Studio 2012 solution. For a 2010 solution use -G”Visual Studio 10″. This should build with 0 errors and 0 warnings. Look for the results in the installed directory. Now, on to TagLib.

  1. Build TagLib much in the same way:

> cd ..\..\taglib-1.9.1
> mkdir build && cd build
> cmake .. -G"Visual Studio 11" -DCMAKE_INSTALL_PREFIX="e:\workspace\lib\installed" -DZLIB_INCLUDE_DIR="e:\workspace\lib\installed\include" -DZLIB_LIBRARY="e:\workspace\lib\installed\lib\zlib.lib" -DWITH_ASF=on -DWITH_MP4=on -DBUILD_EXAMPLES=on
> msbuild /P:Configuration=Release INSTALL.vcxproj

TagLib builds with a number of mostly silly warnings, but no errors. Note that this last part builds a Release configuration; you can use /P:Configuration=Debug but this results in a dll with the same name (i.e. it overwrites the release dll) that links to zlib.dll instead of zlibd.dll. This I will have to address later.

Leave a Reply

Your email address will not be published. Required fields are marked *