<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Compiling PowerDNS on Windows</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PowerDNS manual" HREF="index.html"><LINK REL="UP" TITLE="Compiling PowerDNS" HREF="compiling-powerdns.html"><LINK REL="PREVIOUS" TITLE="Compiling PowerDNS" HREF="compiling-powerdns.html"><LINK REL="NEXT" TITLE="PowerDNS license (GNU General Public License version 2)" HREF="license.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PowerDNS manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="compiling-powerdns.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Appendix D. Compiling PowerDNS</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="license.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="ON-WINDOWS" >D.2. Compiling PowerDNS on Windows</A ></H1 ><P > By Michel Stol (<CODE CLASS="EMAIL" ><<A HREF="mailto:michel@powerdns.com" >michel@powerdns.com</A >></CODE >). </P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN5976" >D.2.1. Assumptions</A ></H2 ><P > I will assume these things from you: </P ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT >You have the PowerDNS sources.</DT ><DD ><P > There's not much to compile without the source files, eh? :) </P ></DD ><DT >You are using Microsoft Visual C++. If you get it to compile using a free compiler, please let us know!</DT ><DD ><P > From the day that we began porting the <ACRONYM CLASS="ACRONYM" >UNIX</ACRONYM > PowerDNS sources to Microsoft Windows we used Microsoft Visual C++ as our development environment of choice. </P ><P > We used Visual C++ 6.0 to compile all sources (both standard version and SP5). Other versions (including Visual C++ .NET) are untested. </P ></DD ><DT >You are using Microsoft Windows NT, 2000 or XP</DT ><DD ><P > 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. </P ><DIV CLASS="NOTE" ><P ></P ><TABLE CLASS="NOTE" WIDTH="90%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/note.gif" HSPACE="5" ALT="Note"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > You probably can compile the sources on other Windows versions too, but that is currently untested. </P ></TD ></TR ></TABLE ></DIV ></DD ><DT >You are using an English Windows version.</DT ><DD ><P > Troughout this document I will use the English names for menu items, names etc., so if you are running a non-English Windows or <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM > version you have to translate those things yourself. But I don't think that would be a big problem. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN6001" >D.2.2. Prequisites</A ></H2 ><P > 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. </P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6004" >D.2.2.1. pthreads for Windows</A ></H3 ><P > The pthreads for Windows library is a Windows implementation of the <ACRONYM CLASS="ACRONYM" >POSIX</ACRONYM > threads specification, which is used a lot in <ACRONYM CLASS="ACRONYM" >UNIX</ACRONYM > programs. </P ><P > PowerDNS uses pthreads too, and to ease the porting process we decided not to reinvent the wheel, but to use pthreads for Windows instead. </P ><DIV CLASS="SECT4" ><H4 CLASS="SECT4" ><A NAME="AEN6010" >D.2.2.1.1. Getting pthreads for Windows</A ></H4 ><P > Pthreads for Windows is available from anonymous ftp at <A HREF="ftp://sources.redhat.com/pub/pthreads-win32/" TARGET="_top" >ftp://sources.redhat.com/pub/pthreads-win32/</A >. You should download the latest <TT CLASS="FILENAME" >pthreads-YYYY-MM-DD.exe</TT > file. </P ><DIV CLASS="NOTE" ><P ></P ><TABLE CLASS="NOTE" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/note.gif" HSPACE="5" ALT="Note"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > PowerDNS for Windows was tested with the snapshot of 2002-03-02 of the library. </P ></TD ></TR ></TABLE ></DIV ><P > For more information you can visit the pthreads for Windows homepage at <A HREF="http://sources.redhat.com/pthreads-win32/" TARGET="_top" >http://sources.redhat.com/pthreads-win32/</A > </P ></DIV ><DIV CLASS="SECT4" ><H4 CLASS="SECT4" ><A NAME="AEN6019" >D.2.2.1.2. Installing pthreads for Windows</A ></H4 ><P > To install the pthreads for Windows library you have to locate your <TT CLASS="FILENAME" >pthreads-YYYY-MM-DD.exe</TT > file and start it. </P ><P > 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 <SPAN CLASS="GUIBUTTON" >Extract</SPAN > button to extract all content to the target directory. </P ><P > The library is now installed, we still have to tell Visual C++ where it's located though, more on that later. </P ></DIV ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN6026" >D.2.3. Nullsoft Installer</A ></H2 ><P > For our installation program we used Nullsoft's Installer System (<ACRONYM CLASS="ACRONYM" >NSIS</ACRONYM >). We used <ACRONYM CLASS="ACRONYM" >NSIS</ACRONYM > because it's easy to use, versatile and free (and it uses <ACRONYM CLASS="ACRONYM" ><SPAN CLASS="TRADEMARK" >SuperPiMP</SPAN >™</ACRONYM > 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 <A HREF="http://www.winamp.com/" TARGET="_top" >winamp</A >. </P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6034" >D.2.3.1. Getting the Nullsoft Installer</A ></H3 ><P > The Nullsoft Installer can be downloaded at their website, which is located at <A HREF="http://www.nullsoft.com/free/nsis/" TARGET="_top" >http://www.nullsoft.com/free/nsis/</A >. The file that you should download is called <TT CLASS="FILENAME" >nsisXXX.exe</TT > (where XXX is the latest version). </P ><DIV CLASS="NOTE" ><P ></P ><TABLE CLASS="NOTE" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/note.gif" HSPACE="5" ALT="Note"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > You can find the <ACRONYM CLASS="ACRONYM" >NSIS</ACRONYM > documentation at that website too. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6042" >D.2.3.2. Installing the Nullsoft Installer</A ></H3 ><P > Installing <ACRONYM CLASS="ACRONYM" >NSIS</ACRONYM > is easy. All there is to it is locating the installer and execute it. Then just follow the installation steps. </P ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN6046" >D.2.4. Setting up the build-environment</A ></H2 ><P > Before starting Microsoft Visual C++ and compile PowerDNS for Windows, you first have to set up your build environment. </P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6049" >D.2.4.1. Make Microsoft Visual C++ recognize <TT CLASS="FILENAME" >*.cc</TT > and <TT CLASS="FILENAME" >*.hh</TT > (optional)</A ></H3 ><P > All PowerDNS source files are in the form <TT CLASS="FILENAME" >name.cc</TT >, and all header files in the form <TT CLASS="FILENAME" >name.hh</TT >. These extensions aren't recognized by <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM > by default, so you might want to change that first. </P ><DIV CLASS="NOTE" ><P ></P ><TABLE CLASS="NOTE" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/note.gif" HSPACE="5" ALT="Note"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > Only perform this step if you want to be able to edit the <TT CLASS="FILENAME" >*.cc</TT > and <TT CLASS="FILENAME" >*.hh</TT > files in <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM >. </P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="CAUTION" ><P ></P ><TABLE CLASS="CAUTION" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/caution.gif" HSPACE="5" ALT="Caution"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > If you decide to perform this step, remember that it requires modification of the Windows registry, always make a backup before modifying! </P ></TD ></TR ></TABLE ></DIV ><P > Ok, after that word of caution we can now proceed. You have to follow these steps: </P ><P ></P ><OL TYPE="1" ><LI ><P > Start the registry editor by entering <TT CLASS="FILENAME" >regedit.exe</TT > in the run prompt (<SPAN CLASS="GUIMENU" >Start->Run...</SPAN >). </P ></LI ><LI ><P > Right click on <TT CLASS="FILENAME" >HKEY_CLASSES_ROOT</TT > and select <SPAN CLASS="GUIMENU" >New->Key</SPAN >. A new key will appear, change that key to <SPAN CLASS="QUOTE" >"<TT CLASS="FILENAME" >.cc</TT >"</SPAN >, then change the default value to <SPAN CLASS="QUOTE" >"cppfile"</SPAN > </P ><P > Then perform the same step for <SPAN CLASS="QUOTE" >"<TT CLASS="FILENAME" >.hh</TT >"</SPAN > (use <SPAN CLASS="QUOTE" >"hfile"</SPAN > instead of <SPAN CLASS="QUOTE" >"cppfile"</SPAN >). </P ></LI ><LI ><P > Go to <TT CLASS="FILENAME" >HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Build System\Components\Platforms\Win32 (x86)\Tools\32-bit C/C++ Compiler for 80x86</TT >. And add <SPAN CLASS="QUOTE" >";*.cc"</SPAN > to the <TT CLASS="FILENAME" >Input_Spec</TT > value (so that it becomes <SPAN CLASS="QUOTE" >"*.c;*.cpp;*.cxx;*.cc"</SPAN >). </P ><DIV CLASS="NOTE" ><P ></P ><TABLE CLASS="NOTE" WIDTH="90%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/note.gif" HSPACE="5" ALT="Note"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > If you happen to use another platform (like alpha) to compile the sources, you have to do the step above for that platform. </P ></TD ></TR ></TABLE ></DIV ></LI ><LI ><P > Go to <TT CLASS="FILENAME" >HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Search</TT >. And add <SPAN CLASS="QUOTE" >";*.cc;*.hh"</SPAN > to the <TT CLASS="FILENAME" >FIF_Filter</TT > value (so that it becomes <SPAN CLASS="QUOTE" >"*.c;*.cpp;*.cxx;*.tli;*.h;*.tlh;*.inl;*.rc;*.cc;*.hh"</SPAN >). </P ></LI ><LI ><P > Finally change <TT CLASS="FILENAME" >HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++</TT >. And add <SPAN CLASS="QUOTE" >";cc;hh"</SPAN > to the <TT CLASS="FILENAME" >FileExtensions</TT > value (so that it becomes <SPAN CLASS="QUOTE" >"cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2;hh;cc"</SPAN >). </P ></LI ><LI ><P > Close the registry editor. </P ></LI ></OL ><P > Now should <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM > properly recognize the files as being C++. </P ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6106" >D.2.4.2. Setting Microsoft Visual C++'s directories</A ></H3 ><P > <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM > needs to locate some include files, libraries and executables when it has to build PowerDNS for Windows. We are now going to tell <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM > where to find those. </P ><P > To enter the directory dialog you have to go to <SPAN CLASS="GUIMENU" >Tools->Options...->Directories</SPAN >. </P ><DIV CLASS="SECT4" ><H4 CLASS="SECT4" ><A NAME="AEN6113" >D.2.4.2.1. Setting the pthreads directories</A ></H4 ><P > When you are in the directory dialog you can add the pthreads for Windows directory. </P ><P > First add the include directory, to do this you have to select <SPAN CLASS="GUILABEL" >Include files</SPAN > from the <SPAN CLASS="GUILABEL" >Show directories for:</SPAN > combobox. Then press the <SPAN CLASS="GUIBUTTON" >New</SPAN > button and browse to the <B CLASS="COMMAND" >include</B > directory of pthreads (ie. <TT CLASS="FILENAME" >C:\pthreads\include</TT >). </P ><P > Then switch to <SPAN CLASS="GUILABEL" >Library files</SPAN > and add the <B CLASS="COMMAND" >library</B > directory (ie. <TT CLASS="FILENAME" >C:\pthreads\lib</TT >) using the same method as above. </P ></DIV ><DIV CLASS="SECT4" ><H4 CLASS="SECT4" ><A NAME="AEN6126" >D.2.4.2.2. Setting the Nullsoft Installer directory</A ></H4 ><P > While still being in the directory dialog, switch to <SPAN CLASS="GUILABEL" >Executable files</SPAN > and add the Nullsoft Installer directory (ie. <TT CLASS="FILENAME" >C:\Program Files\NSIS</TT >) to the list. </P ></DIV ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN6131" >D.2.5. Compilation</A ></H2 ><P > Finally, after all the reading, installing and configuring we are ready to start compiling PowerDNS for Windows. </P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6134" >D.2.5.1. Starting the compilation</A ></H3 ><P > To start the compilation you first have to open the PowerDNS workspace (<TT CLASS="FILENAME" >powerdns.dsw</TT >) using explorer or from the <SPAN CLASS="GUIMENU" >File->Open Workspace...</SPAN > menu in <ACRONYM CLASS="ACRONYM" >MSVC</ACRONYM >. </P ><P > After you opened the workspace you can start compiling. Check all the checkboxes in the <SPAN CLASS="GUIMENU" >Build->Batch Build...</SPAN > menu and press the <SPAN CLASS="GUIBUTTON" >Build</SPAN > button. </P ><P > Now cross your fingers and go make some coffee or tea while compiling PowerDNS for Windows. :) </P ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6144" >D.2.5.2. Yay! It compiled</A ></H3 ><P > Congratulations, you have now compiled PowerDNS for Windows! </P ><P > All the release builds of the binaries are in the <TT CLASS="FILENAME" >Release</TT > directory (including the generated installer). The debug builds are in the, guess what, <TT CLASS="FILENAME" >Debug</TT > directory. </P ><P > Now you can start installing PowerDNS, but that's beyond the scope of this document. See the <A HREF="http://downloads.powerdns.com/documentation/html/" TARGET="_top" >online documentation</A > for more information about that. </P ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6152" >D.2.5.3. What if it went wrong?</A ></H3 ><P > If the compilation fails, then try reading this article again, and again to see if you did something wrong. </P ><P > 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 <CODE CLASS="EMAIL" ><<A HREF="mailto:pdns-dev@mailman.powerdns.com" >pdns-dev@mailman.powerdns.com</A >></CODE > describing your problem. We will then try to fix it. </P ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN6157" >D.2.6. Miscellaneous</A ></H2 ><P > Some miscellaneous information. </P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6160" >D.2.6.1. Credits</A ></H3 ><P ></P ><DIV CLASS="VARIABLELIST" ><P ><B >Michel Stol would like to thank these people:</B ></P ><DL ><DT >Bert Hubert</DT ><DD ><P > For writing the wonderfull PowerDNS software and learning me stuff that I'd otherwise never had learned. </P ></DD ><DT >PowerDNS B.V.</DT ><DD ><P > For being great colleagues. </P ></DD ><DT >The pthreads-win32 crew (see the pthreads-win32 <TT CLASS="FILENAME" >CONTRIBUTORS</TT > file).</DT ><DD ><P > For easing our porting process by writing a great Windows implementation of pthreads. </P ></DD ><DT >The guys over at Nullsoft.</DT ><DD ><P > For creating the Nullsoft Installer System (<ACRONYM CLASS="ACRONYM" >NSIS</ACRONYM >), and Winamp, the program we use every day to make a lot of noise in the office. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6182" >D.2.6.2. Contact information</A ></H3 ><P > If you have a comment, or a bug report concerning either this document or the PowerDNS sources you can contact <CODE CLASS="EMAIL" ><<A HREF="mailto:pdns-dev@mailman.powerdns.com" >pdns-dev@mailman.powerdns.com</A >></CODE > </P ><P > For general information about PowerDNS, the pdns server, express, documentation etc. I advice you to visit <A HREF="http://www.powerdns.com/" TARGET="_top" >http://www.powerdns.com/</A > </P ><P > If you are interested in buying PowerDNS you can send a mail to <CODE CLASS="EMAIL" ><<A HREF="mailto:sales@powerdns.com" >sales@powerdns.com</A >></CODE > or you can visit the PowerDNS website at <A HREF="http://www.powerdns.com/pdns/" TARGET="_top" >http://www.powerdns.com/pdns/</A > </P ><P > 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 <CODE CLASS="EMAIL" ><<A HREF="mailto:michel@powerdns.com" >michel@powerdns.com</A >></CODE > :) </P ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN6193" >D.2.6.3. Legal information</A ></H3 ><P > 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. </P ><P > Other product and company names mentioned herein may be the trademarks of their respective owners. </P ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="compiling-powerdns.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="license.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Compiling PowerDNS</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="compiling-powerdns.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >PowerDNS license (GNU General Public License version 2)</TD ></TR ></TABLE ></DIV ></BODY ></HTML >