By Michel Stol (<michel@powerdns.com>
).
I will assume these things from you:
There's not much to compile without the source files, eh? :)
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.
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.
![]() | You probably can compile the sources on other Windows versions too, but that is currently untested. |
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.
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.
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.
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.
![]() | 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/
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.
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.
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).
![]() | You can find the NSIS documentation at that website too. |
Installing NSIS is easy. All there is to it is locating the installer and execute it. Then just follow the installation steps.
Before starting Microsoft Visual C++ and compile PowerDNS for Windows, you first have to set up your build environment.
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.
![]() | Only perform this step if you want to be able to edit the *.cc and *.hh files in MSVC. |
![]() | 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:
Start the registry editor by entering regedit.exe in the run prompt (Start->Run...).
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").
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").
![]() | If you happen to use another platform (like alpha) to compile the sources, you have to do the step above for that platform. |
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").
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").
Close the registry editor.
Now should MSVC properly recognize the files as being C++.
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.
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.
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.
Finally, after all the reading, installing and configuring we are ready to start compiling PowerDNS for Windows.
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. :)
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.
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 <pdns-dev@mailman.powerdns.com>
describing your
problem. We will then try to fix it.
Some miscellaneous information.
Michel Stol would like to thank these people:
For writing the wonderfull PowerDNS software and learning me stuff that I'd otherwise never had learned.
For being great colleagues.
For easing our porting process by writing a great Windows implementation of pthreads.
For creating the Nullsoft Installer System (NSIS), and Winamp, the program we use every day to make a lot of noise in the office.
If you have a comment, or a bug report concerning either this document or the PowerDNS sources
you can contact <pdns-dev@mailman.powerdns.com>
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 <sales@powerdns.com>
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 <michel@powerdns.com>
:)
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.