D.2. Compiling PowerDNS on Windows

By Michel Stol ().

D.2.1. Assumptions

I will assume these things from you:

You have the PowerDNS sources.

There's not much to compile without the source files, eh? :)

You are using Microsoft Visual C++. If you get it to compile using a free compiler, please let us know!

From the day that we began porting the UNIX PowerDNS sources to Microsoft Windows we used Microsoft Visual C++ as our development environment of choice.

We used Visual C++ 6.0 to compile all sources (both standard version and SP5). Other versions (including Visual C++ .NET) are untested.

You are using Microsoft Windows NT, 2000 or XP

I will assume that the system where you want to compile the sources on is running Microsoft Windows NT, 2000 or XP. These are the operating systems that where found running PowerDNS for Windows.

Note

You probably can compile the sources on other Windows versions too, but that is currently untested.

You are using an English Windows version.

Troughout this document I will use the English names for menu items, names etc., so if you are running a non-English Windows or MSVC version you have to translate those things yourself. But I don't think that would be a big problem.

D.2.2. Prequisites

Although we tried to keep PowerDNS for Windows' dependencies down to a minimum, you will still need some programs and libraries to be able to compile the sources.

D.2.2.1. pthreads for Windows

The pthreads for Windows library is a Windows implementation of the POSIX threads specification, which is used a lot in UNIX programs.

PowerDNS uses pthreads too, and to ease the porting process we decided not to reinvent the wheel, but to use pthreads for Windows instead.

D.2.2.1.1. Getting pthreads for Windows

Pthreads for Windows is available from anonymous ftp at ftp://sources.redhat.com/pub/pthreads-win32/. You should download the latest pthreads-YYYY-MM-DD.exe file.

Note

PowerDNS for Windows was tested with the snapshot of 2002-03-02 of the library.

For more information you can visit the pthreads for Windows homepage at http://sources.redhat.com/pthreads-win32/

D.2.2.1.2. Installing pthreads for Windows

To install the pthreads for Windows library you have to locate your pthreads-YYYY-MM-DD.exe file and start it.

After starting the executable a self-extractor dialog will show up where you can specify where to extract the contents of the file. When you selected a location you can press the Extract button to extract all content to the target directory.

The library is now installed, we still have to tell Visual C++ where it's located though, more on that later.

D.2.3. Nullsoft Installer

For our installation program we used Nullsoft's Installer System (NSIS). We used NSIS because it's easy to use, versatile and free (and it uses SuperPiMP technology, but they refuse to tell us what it is ;)). If the name Nullsoft rings a bell, it's because they're the guys who made winamp.

D.2.3.1. Getting the Nullsoft Installer

The Nullsoft Installer can be downloaded at their website, which is located at http://www.nullsoft.com/free/nsis/. The file that you should download is called nsisXXX.exe (where XXX is the latest version).

Note

You can find the NSIS documentation at that website too.

D.2.3.2. Installing the Nullsoft Installer

Installing NSIS is easy. All there is to it is locating the installer and execute it. Then just follow the installation steps.

D.2.4. Setting up the build-environment

Before starting Microsoft Visual C++ and compile PowerDNS for Windows, you first have to set up your build environment.

D.2.4.1. Make Microsoft Visual C++ recognize *.cc and *.hh (optional)

All PowerDNS source files are in the form name.cc, and all header files in the form name.hh. These extensions aren't recognized by MSVC by default, so you might want to change that first.

Note

Only perform this step if you want to be able to edit the *.cc and *.hh files in MSVC.

Caution

If you decide to perform this step, remember that it requires modification of the Windows registry, always make a backup before modifying!

Ok, after that word of caution we can now proceed. You have to follow these steps:

  1. Start the registry editor by entering regedit.exe in the run prompt (Start->Run...).

  2. Right click on HKEY_CLASSES_ROOT and select New->Key. A new key will appear, change that key to ".cc", then change the default value to "cppfile"

    Then perform the same step for ".hh" (use "hfile" instead of "cppfile").

  3. Go to HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Build System\Components\Platforms\Win32 (x86)\Tools\32-bit C/C++ Compiler for 80x86. And add ";*.cc" to the Input_Spec value (so that it becomes "*.c;*.cpp;*.cxx;*.cc").

    Note

    If you happen to use another platform (like alpha) to compile the sources, you have to do the step above for that platform.

  4. Go to HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Search. And add ";*.cc;*.hh" to the FIF_Filter value (so that it becomes "*.c;*.cpp;*.cxx;*.tli;*.h;*.tlh;*.inl;*.rc;*.cc;*.hh").

  5. Finally change HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++. And add ";cc;hh" to the FileExtensions value (so that it becomes "cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2;hh;cc").

  6. Close the registry editor.

Now should MSVC properly recognize the files as being C++.

D.2.4.2. Setting Microsoft Visual C++'s directories

MSVC needs to locate some include files, libraries and executables when it has to build PowerDNS for Windows. We are now going to tell MSVC where to find those.

To enter the directory dialog you have to go to Tools->Options...->Directories.

D.2.4.2.1. Setting the pthreads directories

When you are in the directory dialog you can add the pthreads for Windows directory.

First add the include directory, to do this you have to select Include files from the Show directories for: combobox. Then press the New button and browse to the include directory of pthreads (ie. C:\pthreads\include).

Then switch to Library files and add the library directory (ie. C:\pthreads\lib) using the same method as above.

D.2.4.2.2. Setting the Nullsoft Installer directory

While still being in the directory dialog, switch to Executable files and add the Nullsoft Installer directory (ie. C:\Program Files\NSIS) to the list.

D.2.5. Compilation

Finally, after all the reading, installing and configuring we are ready to start compiling PowerDNS for Windows.

D.2.5.1. Starting the compilation

To start the compilation you first have to open the PowerDNS workspace (powerdns.dsw) using explorer or from the File->Open Workspace... menu in MSVC.

After you opened the workspace you can start compiling. Check all the checkboxes in the Build->Batch Build... menu and press the Build button.

Now cross your fingers and go make some coffee or tea while compiling PowerDNS for Windows. :)

D.2.5.2. Yay! It compiled

Congratulations, you have now compiled PowerDNS for Windows!

All the release builds of the binaries are in the Release directory (including the generated installer). The debug builds are in the, guess what, Debug directory.

Now you can start installing PowerDNS, but that's beyond the scope of this document. See the online documentation for more information about that.

D.2.5.3. What if it went wrong?

If the compilation fails, then try reading this article again, and again to see if you did something wrong.

If you are pretty sure that it's a bug, either in the PowerDNS sources, the build system or in this article, then please send an e-mail to describing your problem. We will then try to fix it.

D.2.6. Miscellaneous

Some miscellaneous information.

D.2.6.1. Credits

Michel Stol would like to thank these people:

Bert Hubert

For writing the wonderfull PowerDNS software and learning me stuff that I'd otherwise never had learned.

PowerDNS B.V.

For being great colleagues.

The pthreads-win32 crew (see the pthreads-win32 CONTRIBUTORS file).

For easing our porting process by writing a great Windows implementation of pthreads.

The guys over at Nullsoft.

For creating the Nullsoft Installer System (NSIS), and Winamp, the program we use every day to make a lot of noise in the office.

D.2.6.2. Contact information

If you have a comment, or a bug report concerning either this document or the PowerDNS sources you can contact

For general information about PowerDNS, the pdns server, express, documentation etc. I advice you to visit http://www.powerdns.com/

If you are interested in buying PowerDNS you can send a mail to or you can visit the PowerDNS website at http://www.powerdns.com/pdns/

If you want to praise my work, ask me to marry you, deposit $1.000.000 on my bank account or flame me to death, then you can mail me at :)

D.2.6.3. Legal information

Microsoft, Visual C++, Windows, Windows NT, Windows 2000, Windows XP and Win32 are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.

Other product and company names mentioned herein may be the trademarks of their respective owners.