]> granicus.if.org Git - apache/blob - docs/manual/platform/win_compiling.xml
Fix alignment in a <highlight> block.
[apache] / docs / manual / platform / win_compiling.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="win_compiling.xml.meta">
24   <parentdocument href="./">Platform Specific Notes</parentdocument>
25
26   <title>Compiling Apache for Microsoft Windows</title>
27
28   <summary>
29
30     <p>There are many important points to consider before you begin compiling
31     Apache HTTP Server (httpd). See <a href="windows.html">Using Apache HTTP
32     Server on Microsoft Windows</a> before you begin.</p>
33
34     <p>httpd can be built on Windows using a cmake-based build system or with
35     Visual Studio project files maintained by httpd developers.  The cmake-based
36     build system directly supports more versions of Visual Studio but currently
37     has considerable functional limitations.</p>
38
39   </summary>
40
41   <section id="vstudio">
42   <title>Building httpd with the included Visual Studio project files</title>
43
44   <section id="requirements">
45
46     <title>Requirements</title>
47
48     <p>Compiling Apache requires the following environment to be
49     properly installed:</p>
50
51     <ul>
52       <li>
53         <p>Disk Space</p>
54
55         <p>Make sure you have at least 200 MB of free disk space
56         available. After installation Apache requires approximately
57         80 MB of disk space, plus space for log and cache files,
58         which can grow rapidly. The actual disk space requirements
59         will vary considerably based on your chosen configuration and
60         any third-party modules or libraries, especially when OpenSSL
61         is also built.  Because many files are text and very easily
62         compressed, NTFS filesystem compression cuts these requirements
63         in half.</p>
64       </li>
65
66       <li>
67         <p>Appropriate Patches</p>
68
69         <p>The httpd binary is built with the help of several patches to
70         third party packages, which ensure the released code is buildable
71         and debuggable.  These patches are available and distributed from <a
72         href="http://www.apache.org/dist/httpd/binaries/win32/patches_applied/"
73         >http://www.apache.org/dist/httpd/binaries/win32/patches_applied/</a>
74         and are recommended to be applied to obtain identical results as the
75         "official" ASF distributed binaries.</p>
76       </li>
77
78       <li>
79         <p>Microsoft Visual C++ 6.0 (Visual Studio 97) or later.</p>
80
81         <p>Apache can be built using the command line tools, or from
82         within the Visual Studio IDE Workbench.  The command line
83         build requires the environment to reflect the <code>PATH</code>,
84         <code>INCLUDE</code>, <code>LIB</code> and other variables
85         that can be configured with the <code>vcvars32.bat</code> script.</p>
86
87         <note>You may want the Visual Studio Processor Pack for your older
88         version of Visual Studio, or a full (not Express) version of newer
89         Visual Studio editions, for the ml.exe assembler.  This will allow
90         you to build OpenSSL, if desired, using the more efficient assembly
91         code implementation.</note>
92
93         <note>Only the Microsoft compiler tool chain is actively supported by
94         the active httpd contributors.  Although the project regularly accepts
95         patches to ensure MinGW and other alternative builds work and improve
96         upon them, they are not actively maintained and are often broken in
97         the course of normal development.</note>
98       </li>
99
100       <li>
101         <p>Updated Microsoft Windows Platform SDK, February 2003 or later.</p>
102
103         <p>An appropriate Windows Platform SDK is included by default in the
104         full (not express/lite) versions  of Visual C++ 7.1 (Visual Studio 2002)
105         and later, these users can ignore these steps unless explicitly choosing
106         a newer or different version of the Platform SDK.</p>
107
108         <p>To use Visual C++ 6.0 or 7.0 (Studio 2000 .NET), the Platform SDK
109         environment must be prepared using the <code>setenv.bat</code>
110         script (installed by the Platform SDK) before starting the command
111         line build or launching the msdev/devenv GUI environment.  Installing
112         the Platform SDK for Visual Studio Express versions (2003 and later)
113         should adjust the default environment appropriately.</p>
114
115         <example>
116           "c:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32"<br />
117           "c:\Program Files\Platform SDK\setenv.bat"
118         </example>
119       </li>
120
121       <li>
122         <p>Perl and awk</p>
123
124         <p>Several steps recommended here require a perl interpreter during
125         the build preparation process, but it is otherwise not required.</p>
126
127         <p>To install Apache within the build system, several files are
128         modified using the <code>awk.exe</code> utility. awk was chosen since
129         it is a very small download (compared with Perl or WSH/VB) and
130         accomplishes the task of modifying configuration files upon
131         installation.  Brian Kernighan's
132         <a href="http://www.cs.princeton.edu/~bwk/btl.mirror/"
133         >http://www.cs.princeton.edu/~bwk/btl.mirror/</a>
134         site has a compiled native Win32 binary,
135         <a href="http://www.cs.princeton.edu/~bwk/btl.mirror/awk95.exe"
136         >http://www.cs.princeton.edu/~bwk/btl.mirror/awk95.exe</a> which
137         you must save with the name <code>awk.exe</code> (rather than
138         <code>awk95.exe</code>).</p>
139
140         <note>If awk.exe is not found, Makefile.win's install target
141         will not perform substitutions in the installed .conf files.
142         You must manually modify the installed .conf files to allow
143         the server to start.  Search and replace all "@token@" tags
144         as appropriate.</note>
145
146         <note>The Visual Studio IDE will only find <code>awk.exe</code>
147         from the PATH, or executable path specified in the menu option
148         Tools -&gt; Options -&gt; (Projects -&gt;) Directories.  Ensure
149         awk.exe is in your system path.</note>
150
151         <note>Also note that if you are using Cygwin tools
152         (<a href="http://www.cygwin.com/">http://www.cygwin.com/</a>)
153         the awk utility is named <code>gawk.exe</code> and that the file
154         <code>awk.exe</code> is really a symlink to the <code>gawk.exe</code>
155         file. The Windows command shell does not recognize symlinks, and
156         because of this building InstallBin will fail. A workaround is
157         to delete <code>awk.exe</code> from the cygwin installation and
158         copy <code>gawk.exe</code> to <code>awk.exe</code>.  Also note the
159         cygwin/mingw ports of gawk 3.0.x were buggy, please upgrade to 3.1.x
160         before attempting to use any gawk port.</note>
161       </li>
162
163       <li>
164         <p>[Optional] zlib library (for <module>mod_deflate</module>)</p>
165
166         <p>Zlib must be installed into a <code>srclib</code> subdirectory named
167         <code>zlib</code>.  This must be built in-place.  Zlib can be obtained
168         from <a href="http://www.zlib.net/">http://www.zlib.net/</a> -- the
169         <module>mod_deflate</module> is confirmed to work correctly with
170         version 1.2.3.</p>
171
172         <example>
173           nmake -f win32\Makefile.msc<br />
174           nmake -f win32\Makefile.msc test
175         </example>
176       </li>
177
178       <li>
179         <p>[Optional] OpenSSL libraries (for <module>mod_ssl</module>
180         and <code>ab.exe</code> with ssl support)</p>
181
182         <note>The OpenSSL library is cryptographic software.  The country
183         in which you currently reside may have restrictions on the import,
184         possession, use, and/or re-export to another country, of encryption
185         software.  BEFORE using any encryption software, please check your
186         country's laws, regulations and policies concerning the import,
187         possession, or use, and re-export of encryption software, to see
188         if this is permitted.  See
189         <a href="http://www.wassenaar.org/">http://www.wassenaar.org/</a>
190         for more information.</note>
191
192         <p>Configuring and building OpenSSL requires perl to be installed.</p>
193
194         <p>OpenSSL must be installed into a <code>srclib</code> subdirectory
195         named <code>openssl</code>, obtained from
196         <a href="http://www.openssl.org/source/"
197         >http://www.openssl.org/source/</a>, in order to compile
198         <module>mod_ssl</module> or the <code>abs.exe</code> project, which
199         is ab.c with SSL support enabled.  To prepare OpenSSL to be linked
200         to Apache mod_ssl or abs.exe, and disable patent encumbered features
201         in OpenSSL,  you might use the following build commands:</p>
202
203         <example>
204           perl Configure no-rc5 no-idea enable-mdc2 enable-zlib VC-WIN32
205                -Ipath/to/srclib/zlib -Lpath/to/srclib/zlib<br />
206           ms\do_masm.bat<br />
207           nmake -f ms\ntdll.mak
208         </example>
209
210         <note>It is not advisable to use zlib-dynamic, as that transfers
211         the cost of deflating SSL streams to the first request which must
212         load the zlib dll.  Note the suggested patch enables the -L flag to
213         work with windows builds, corrects the name of zdll.lib and ensures
214         .pdb files are generated for troubleshooting.  If the assembler is
215         not installed, you would add no-asm above and use ms\do_ms.bat
216         instead of the ms\do_masm.bat script.</note>
217       </li>
218
219       <li>
220         <p>[Optional] Database libraries (for <module>mod_dbd</module>
221         and <module>mod_authn_dbm</module>)</p>
222
223         <p>The apr-util library exposes dbm (keyed database) and dbd (query
224         oriented database) client functionality to the httpd server and its
225         modules, such as authentication and authorization.  The sdbm dbm and
226         odbc dbd providers are compiled unconditionally.</p>
227
228         <p>The dbd support includes the Oracle instantclient package, MySQL,
229         PostgreSQL and sqlite.  To build these all, for example, set up the
230         LIB to include the library path, INCLUDE to include the headers path,
231         and PATH to include the dll bin path of all four SDK's, and set the
232         DBD_LIST environment variable to inform the build which client driver
233         SDKs are installed correctly, e.g.;</p>
234
235         <example>
236           set DBD_LIST=sqlite3 pgsql oracle mysql
237         </example>
238
239         <p>Similarly, the dbm support can be extended with DBM_LIST to
240         build a Berkeley DB provider (db) and/or gdbm provider, by similarly
241         configuring LIB, INCLUDE and PATH first to ensure the client library
242         libs and headers are available.</p>
243
244         <example>
245           set DBM_LIST=db gdbm
246         </example>
247
248         <note>Depending on the choice of database distributions, it may be
249         necessary to change the actual link target name (e.g. gdbm.lib vs.
250         libgdb.lib) that are listed in the corresponding .dsp/.mak files
251         within the directories srclib\apr-util\dbd or ...\dbm.</note>
252
253         <p>See the README-win32.txt file for more hints on obtaining the
254         various database driver SDKs.</p>
255       </li>
256     </ul>
257
258   </section>
259
260   <section id="unixsrcbuild">
261
262     <title>Building from Unix sources</title>
263
264     <p>The policy of the Apache HTTP Server project is to only release Unix sources.
265     Windows source packages made available for download have been supplied by
266     volunteers and may not be available for every release. You can still build
267     the server on Windows from the Unix source tarball with just a few additional
268     steps.</p>
269
270     <ol>
271         <li>Download and unpack the Unix source tarball for the latest version.</li>
272         <li>Download and unpack the Unix source tarball for latest version of
273         APR, AR-Util and APR-Iconv, place these sources in directories  httpd-2.x.x\srclib\apr, httpd-2.x.x\srclib\apr-util and httpd-2.x.x\srclib\apr-iconv</li>
274         <li>Open a Command Prompt and CD to the httpd-2.x.x folder</li>
275         <li>Run the line endings conversion utility at the prompt;</li>
276     </ol>
277
278     <example>
279       perl srclib\apr\build\lineends.pl
280     </example>
281
282     <p>You can now build the server with the Visual Studio 6.0 development
283     environment using the IDE. Command-Line builds of the server are not
284     possible from Unix sources unless you export .mak files as explained
285     below.
286     </p>
287
288   </section>
289
290   <section id="commandbuild">
291
292     <title>Command-Line Build</title>
293
294     <p><code>Makefile.win</code> is the top level Apache makefile.
295     To compile Apache on Windows, simply use one of the following commands
296     to build the <code>release</code> or <code>debug</code> flavor:</p>
297
298     <example>
299       nmake /f Makefile.win _apacher<br /><br />
300       nmake /f Makefile.win _apached
301     </example>
302
303     <p>Either command will compile Apache. The latter will disable
304     optimization of the resulting files, making it easier to single
305     step the code to find bugs and track down problems.</p>
306
307     <p>You can add your apr-util dbd and dbm provider choices with the
308     additional make (environment) variables DBD_LIST and DBM_LIST,
309     see the comments about [Optional] Database libraries, above.
310     Review the initial comments in Makefile.win for additional options
311     that can be provided when invoking the build.</p>
312
313   </section>
314
315   <section id="workspacebuild">
316
317     <title>Developer Studio Workspace IDE Build</title>
318
319     <p>Apache can also be compiled using VC++'s Visual Studio
320     development environment. To simplify this process, a
321     Visual Studio workspace, <code>Apache.dsw</code>, is provided.
322     This workspace exposes the entire list of working <code>.dsp</code>
323     projects that are required for the complete Apache binary release.
324     It includes dependencies between the projects to assure that they
325     are built in the appropriate order.</p>
326
327     <p>Open the <code>Apache.dsw</code> workspace, and select
328     <code>InstallBin</code> (<code>Release</code> or <code>Debug</code> build,
329     as desired) as the Active Project. <code>InstallBin</code> causes all
330     related project to be built, and then invokes <code>Makefile.win</code> to
331     move the compiled executables and dlls. You may personalize the
332     <code>INSTDIR=</code> choice by changing <code>InstallBin</code>'s Settings,
333     General tab, Build command line entry. <code>INSTDIR</code> defaults to the
334     <code>/Apache2</code> directory. If you only want a test compile (without
335     installing) you may build the <code>BuildBin</code> project instead.</p>
336
337     <p>The <code>.dsp</code> project files are distributed in Visual Studio 6.0
338     (98) format. Visual C++ 5.0 (97) will recognize them. Visual Studio
339     2002 (.NET) and later users must convert <code>Apache.dsw</code> plus
340     the <code>.dsp</code> files into an <code>Apache.sln</code> plus
341     <code>.msproj</code> files.  Be sure you reconvert the <code>.msproj</code>
342     file again if its source <code>.dsp</code> file changes! This is really
343     trivial, just open <code>Apache.dsw</code> in the VC++ 7.0 IDE once again
344     and reconvert.</p>
345
346     <note>There is a flaw in the .vcproj conversion of .dsp files.  devenv.exe
347     will mis-parse the /D flag for RC flags containing long quoted /D'efines
348     which contain spaces.  The command:
349     <example>
350       perl srclib\apr\build\cvtdsp.pl -2005
351     </example>
352     will convert the /D flags for RC flags to use an alternate, parseable
353     syntax; unfortunately this syntax isn't supported by Visual Studio 97
354     or its exported .mak files.  These /D flags are used to pass the long
355     description of the mod_apachemodule.so files to the shared .rc resource
356     version-identifier build.</note>
357
358     <p>Visual Studio 2002 (.NET) and later users should also use the Build
359     menu, Configuration Manager dialog to uncheck both the <code>Debug</code>
360     and <code>Release</code> Solution modules <code>abs</code>,
361     <module>mod_deflate</module> and <module>mod_ssl</module> components, as
362     well as every component starting with <code>apr_db*</code>.  These modules
363     are built by invoking <code>nmake</code>, or the IDE directly with the
364     <code>BinBuild</code> target, which builds those modules conditionally
365     if the <code>srclib</code> directories <code>openssl</code> and/or
366     <code>zlib</code> exist, and based on the setting of <code>DBD_LIST</code>
367     and <code>DBM_LIST</code> environment variables.</p>
368
369   </section>
370
371   <section id="exportingmakfiles">
372
373     <title>Exporting command-line .mak files</title>
374
375     <p>Exported <code>.mak</code> files pose a greater hassle, but they are
376     required for Visual C++ 5.0 users to build <module>mod_ssl</module>,
377     abs (<program>ab</program> with SSL support) and/or
378     <module>mod_deflate</module>.  The .mak files also support a broader
379     range of C++ tool chain distributions, such as Visual Studio Express.</p>
380
381     <p>You must first build all projects in order to create all dynamic
382     auto-generated targets, so that dependencies can be parsed correctly.
383     Build the entire project from within the Visual Studio 6.0 (98) IDE,
384     using the <code>BuildAll</code> target, then use the Project Menu Export
385     for all makefiles (checking on "with dependencies".)  Run the following
386     command to correct absolute paths into relative paths so they will build
387     anywhere:</p>
388
389     <example>
390       perl srclib\apr\build\fixwin32mak.pl
391     </example>
392
393     <p>You must type this command from the <em>top level</em>
394     directory of the httpd source tree. Every
395     <code>.mak</code> and <code>.dep</code> project file within
396     the current directory and below will be corrected, and the
397     timestamps adjusted to reflect the <code>.dsp</code>.</p>
398
399     <p>Always review the generated <code>.mak</code> and <code>.dep</code>
400     files for Platform SDK or other local, machine specific file paths.
401     The <code>DevStudio\Common\MSDev98\bin\</code> (VC6) directory contains
402     a <code>sysincl.dat</code> file, which lists all exceptions.  Update
403     this file (including both forward and backslashed paths, such as both
404     <code>sys/time.h</code> and <code>sys\time.h</code>) to ignore such
405     newer dependencies.  Including local-install paths in a distributed
406     <code>.mak</code> file will cause the build to fail completely.</p>
407
408     <p>If you contribute back a patch that revises project files, we
409     must commit project files in Visual Studio 6.0 format. Changes
410     should be simple, with minimal compilation and linkage flags that
411     can be recognized by all Visual Studio environments.</p>
412
413   </section>
414
415   <section id="installation">
416
417     <title>Installation</title>
418
419     <p>Once Apache has been compiled, it needs to be installed in
420     its server root directory. The default is the
421     <code>\Apache2</code> directory, of the same drive.</p>
422
423     <p>To build and install all the files into the desired folder
424     <em>dir</em> automatically, use one of the following
425     <code>nmake</code> commands:</p>
426
427     <example>
428       nmake /f Makefile.win installr INSTDIR=<em>dir</em><br />
429       nmake /f Makefile.win installd INSTDIR=<em>dir</em>
430     </example>
431
432     <p>The <em>dir</em> argument to <code>INSTDIR</code> provides
433     the installation directory; it can be omitted if Apache is
434     to be installed into <code>\Apache22</code> (of the current
435     drive).</p>
436
437   </section>
438
439   <section id="projectcomponents-warn">
440
441     <title>Warning about building Apache from the development tree</title>
442
443     <note>Note only the <code>.dsp</code> files are maintained between <code>release</code>
444     builds. The <code>.mak</code> files are NOT regenerated, due to the tremendous
445     waste of reviewer's time. Therefore, you cannot rely on the <code>NMAKE</code>
446     commands above to build revised <code>.dsp</code> project files unless you
447     then export all <code>.mak</code> files yourself from the project. This is
448     unnecessary if you build from within the Microsoft
449     Developer Studio environment.</note>
450
451   </section>
452   </section>
453
454   <section id="cmake">
455   <title>Building httpd with cmake</title>
456
457   <p>The primary documentation for this build mechanism is in the
458   <code>README.cmake</code> file in the source distribution.  Refer to that file
459   for detailed instructions.</p>
460
461   <p>Building httpd with cmake requires building APR and APR-util separately.
462   Refer to their <code>README.cmake</code> files for instructions.</p>
463
464   <p>The primary limitations of the cmake-based build are inherited from the APR-util
465   project, and are listed below because of their impact on httpd:</p>
466
467   <ul>
468     <li>No cmake build for the APR-iconv subproject is available, and the
469       APR-util cmake build cannot consume an existing APR-iconv build.  Thus,
470       <module>mod_charset_lite</module> and possibly some third-party modules
471       cannot be used.</li>
472     <li>The cmake build for the APR-util subproject does not support most of the
473       optional DBM and DBD libraries supported by the included Visual Studio
474       project files.  This limits the database backends supported by a number of
475       bundled and third-party modules.</li>
476   </ul>
477
478   </section>
479
480 </manualpage>