Building TagLib on Windows – part 2

Last time I left of with a built Release version of TagLib, but no good way to also have a Debug build. Let’s see if I can change that. For the next commands we need the appropriate Visual Studio Command Prompt.

For Release:

> 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

For Debug:

> cmake .. -G"Visual Studio 11" -DCMAKE_DEBUG_POSTFIX="d" -DCMAKE_INSTALL_PREFIX="e:\workspace\lib\installed" -DZLIB_INCLUDE_DIR="e:\workspace\lib\installed\include" -DZLIB_LIBRARY="e:\workspace\lib\installed\lib\zlibd.lib" -DWITH_ASF=on -DWITH_MP4=on -DBUILD_EXAMPLES=on
> msbuild /P:Configuration=Debug INSTALL.vcxproj

Note the difference in the ZLIB_LIBRARY: zlib.lib vs zlibd.lib. Also note the addition of -DCMAKE_DEBUG_POSTFIX=”d”. This results in a file tagd.dll for the debug build.

Normally you would like to generate the project once and then build multiple configurations. The trouble is that we need to specify the ZLIB library which is different for Debug and Release. The FindZLIB.cmake module apparently is unable to correctly find the Debug version.

So now we have a Debug and a Release version of the library. That’s nice, but to goal is to use TagLib, so that the application automatically finds the TagLib headers and links to the correct library.

In the next article I will present my FindTagLib.cmake module to do just that.

Leave a Reply

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