Project

General

Profile

Installing Wt on MS Windows » History » Version 11

Pieter Libin, 10/29/2009 01:51 PM

1 1 Pieter Libin
h1. Installing Wt on MS Windows
2
3
{{toc}}
4
5
This HOWTO assumes you have a clean Windows system and want to use Wt. We start with the download of the compiler and system libraries. We continue to explain where the dependency libraries can be found and how they are installed. Then the configuration of Wt is covered, and finally we build Wt and run the examples.
6
7
<b>Wt version 2.1.x has its own installation instructions: [[Installing Wt 2.1 on MS Windows]]</b>
8
9
Unlike Linux distributions, Windows has no easy package manager for developers. This means that you will have to compile everything from scratch, and that there is very little similarity between the packages with respect to how and where they are installed. This HOWTO proposes a directory structure that will work with Wt's cmake configuration. We have made a significant progress toward minimizing the amount of obligatory dependency projects, but there are still a few left.
10
11
These instructions have been tested both on Windows XP and Windows Vista.
12
13
<b>You are looking at an old HOWTO, applicable only for older versions of Wt (< 2.0.5). See [[Installing Wt 2.1 on MS Windows]] for the latest information.</b>
14
15
16
h2. Setting up your compiler 
17
18
You need either Microsoft Visual Studio 2005 Professional or Microsoft Visual Studio 2005 Express Edition (C++). The difference is that the former is payware, whereas the latter is a free reduced version of MSVC. The good news is that the Express Edition is perfect to compile Wt.
19
20
For more information about the compiler, see [[Installing MSVC 2005]].
21
22
23
h2. Installing Wt's dependencies 
24
25
26
h3. Preparations 
27
28
In order to avoid to set paths to small library separately, we create a repository where we store them all. CMake will find this repository without intervention if you call it 'c:\libraries'.
29 10 Pieter Libin
 <pre>
30 1 Pieter Libin
mkdir c:\libraries
31
mkdir c:\libraries\lib
32
mkdir c:\libraries\include
33 10 Pieter Libin
 </pre>
34 1 Pieter Libin
35
36
h3. Boost 
37
38
The developers have mainly used boost 1.33.1 up till now. The boost.org recently released version 1.34 of their libraries, which are slightly different to set up. Boost does not include the asio library, so it has to be installed separately. You can choose to install either 1.33.1 or 1.34, or both, even with the same prefix.
39
40
41
h4. Version 1.33.1 
42
43 10 Pieter Libin
* Download the boost sources (boost_1_33_1.tar.bz2) from http://www.boost.org/
44
* Download the binary of bjam (boost-jam-3.1.14-1-ntx86.zip)
45
* Extract the boost sources, e.g. in c:\tmp\boostbuild
46
* Extract bjam and copy it in the boost directory (c:\tmp\boostbuild\boost_1_33_1)
47
* Start a Visual Studio 2005 Command Prompt (Start->All Programs->Visual Studio 2005->Visual Studio Tools)
48
* Change to your boost build directory (cd \tmp\boostbuild\boost_1_33_1)
49
* Run bjam:
50 9 Pieter Libin
 <pre>
51 10 Pieter Libin
bjam "-sTOOLS=vc-8_0" "--prefix=c:\libraries" install
52 9 Pieter Libin
 </pre>
53 10 Pieter Libin
* Ignore messages about python and others
54 1 Pieter Libin
55
56
h4. Version 1.34.1 
57
58
* Download the boost sources (boost_1_34_1.tar.bz2) from http://www.boost.org/
59
* Download the binary of bjam (boost-jam-3.1.14-1-ntx86.zip)
60
* Extract the boost sources, e.g. in c:/tmp/boostbuild
61
* Extract bjam and copy it in the boost directory (c:\tmp\boostbuild\boost_1_34_1)
62
* Start a Visual Studio 2005 Command Prompt (Start->All Programs->Visual Studio 2005->Visual Studio Tools)
63
* Change to your boost build directory (cd \tmp\boostbuild\boost_1_34_1)
64
* Run bjam:
65 10 Pieter Libin
 <pre>
66 1 Pieter Libin
bjam --toolset=msvc-8.0 --prefix=c:\libraries install
67 10 Pieter Libin
 </pre>
68 1 Pieter Libin
69
70
h4. Boost asio 
71
72
* Download boost asio from http://asio.sourceforge.net/ (boost_asio_0_3_7.tar.bz2; newer versions will not work without extra modifications)
73
* Untar boost asio inside boost's include directory (c:\libraries\include\boost)
74
* Apply this "patch":http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-cpp/asio/files/asio-0.3.7-recursive_init.patch?rev=1.1&view=markup to boost asio:
75 10 Pieter Libin
 <pre>
76 1 Pieter Libin
--- ./include/asio/ssl/detail/openssl_init.hpp.orig	2006-11-15 00:10:08.000000000 +0100
77
+++ ./include/asio/ssl/detail/openssl_init.hpp	2006-11-15 00:10:38.000000000 +0100
78
@@ -45,13 +45,13 @@
79
       {
80
         ::SSL_library_init();
81
         ::SSL_load_error_strings();        
82 10 Pieter Libin
+        ::OpenSSL_add_ssl_algorithms();
83 11 Pieter Libin
84 1 Pieter Libin
         mutexes_.resize(::CRYPTO_num_locks());
85
         for (size_t i = 0; i < mutexes_.size(); ++i)
86
           mutexes_[i].reset(new asio::detail::mutex);
87
         ::CRYPTO_set_locking_callback(&do_init::openssl_locking_func);
88 10 Pieter Libin
 
89
-        ::OpenSSL_add_ssl_algorithms();
90 1 Pieter Libin
       }
91 10 Pieter Libin
     }
92 1 Pieter Libin
93 10 Pieter Libin
 </pre>
94 4 Pieter Libin
95 1 Pieter Libin
Boost asio is a headerfile-only library, so no compilation is required.
96
97
98
h3. MXML 
99
100
Wt now includes MXML as part of the download and build process. MXML is no longer a dependency; it is mentioned here only because it is required for older versions of Wt.
101
102
Newer versions of Wt use mxml instead of Xerces. Mxml is much smaller and depends on much less than Xerces, so for our purpose that is good news.
103
* Download "Mini-XML":http://www.minixml.org/ (mxml-2.3.tar.gz)
104
* Apply the following patch to avoid compile errors:
105 10 Pieter Libin
 <pre>
106 1 Pieter Libin
--- mxml-2.3-orig/mxml-string.c 2007-04-18 15:14:10.000000000 +0200
107
+++ mxml-2.3/mxml-string.c      2007-07-07 14:59:58.697309500 +0200
108
@@ -30,6 +30,7 @@
109 10 Pieter Libin
110
 #include "config.h"
111 1 Pieter Libin
112
+char *_mxml_vstrdupf(const char *format, va_list ap);
113 10 Pieter Libin
114 1 Pieter Libin
 #ifdef HAVE_SNPRINTF
115 10 Pieter Libin
 /*
116
117 1 Pieter Libin
--- mxml-2.3-orig/vcnet/config.h        2007-04-18 15:14:10.000000000 +0200
118
+++ mxml-2.3/vcnet/config.h     2007-07-07 18:01:18.009809500 +0200
119 10 Pieter Libin
@@ -48,9 +48,9 @@
120 1 Pieter Libin
 /*
121
  * Do we have the snprintf() and vsnprintf() functions?
122 10 Pieter Libin
  */
123 1 Pieter Libin
-
124
-/*#undef HAVE_SNPRINTF */
125
-/*#undef HAVE_VSNPRINTF */
126
+#define snprintf _snprintf
127
+#define HAVE_SNPRINTF 1
128
+#define HAVE_VSNPRINTF 1
129
130 10 Pieter Libin
131
 /*
132 4 Pieter Libin
133 10 Pieter Libin
 </pre>
134 1 Pieter Libin
* Open the solution mxml-2.3\vcnet\mxml.sln. Convert the solution to a 2005 solution by clicking 'Finish'.
135
* Build both the debug and the release version of the library: First select 'Debug' as Solution Configuration and right-click on mxml and select Build; then select 'Release' as Solution configuration and right-click on mxml and select Build again.
136
137
Two static libraries have been built now: mxml.lib and mxmld.lib. We copy them, together with the header files, to our central repository directory:
138 10 Pieter Libin
 <pre>
139 1 Pieter Libin
cp mxml.h c:\libraries\include
140
cp *.lib c:\libraries\lib
141 10 Pieter Libin
 </pre>
142 1 Pieter Libin
143
144
145
h3. zlib 
146
147
* Download "zlib":http://www.zlib.net/zlib-1.2.3.tar.gz
148
* Open zlib-1.2.3\contrib\vstudio\vc8\zlibvc.sln
149
* Select solution 'Debug', architecture 'Win32' and press F7 (Build all)
150
* Select solution 'Release', architecture 'Win32' and press F7 (Build all)
151
152
Results are now located in the x86 directory. We can use either the dynamic libraries (ZlibDll*) or the static libraries (ZlibStat*). We assume the static libraries (they're less hassle at runtime). Copy them into our central repository location, renaming the debug library in the process:
153 10 Pieter Libin
 <pre>
154 1 Pieter Libin
cp contrib\vstudio\vc8\x86\ZlibStatDebug\zlibstat.lib c:\libraries\lib\zlibstatd.lib
155
cp contrib\vstudio\vc8\x86\ZlibStatRelease\zlibstat.lib c:\libraries\lib\
156 10 Pieter Libin
 </pre>
157 1 Pieter Libin
158
We also need zlib.h and zconf.h header files.
159 10 Pieter Libin
 <pre>
160 1 Pieter Libin
cp zlib.h zconf.h c:\libraries\include
161 10 Pieter Libin
 </pre>
162 1 Pieter Libin
163
h3. cmake 
164
165
* Download the Win32 Installer (cmake-2.4.6-win32-x86.exe) from http://www.cmake.org/
166
* Run the installer
167
168
CMake is now ready for use.
169
170
171
h3. OpenSSL (optional) 
172
173
OpenSSL is used by the wthttpd connector to support encrypted links over http (SSL). The compilation of the OpenSSL library will be covered later.
174
175
176
h3. libgd (optional) 
177
178
179
h3. libmysql (optional) 
180
181
182
h3. libmysql++ (optional) 
183
184
185
h3. cygwin (optional) 
186
187
I prefer to use cygwin (http://www.cygwin.com/) for cvs access over ssh. Other options are available, and you don't even need CVS access unless you want the bleeding edge Wt version.
188
189
190
h2. Download Wt 
191
192
The following versions of Wt are known to compile according to the instructions of this HOWTO:
193
* None
194
Feel free to report success here if we forgot to add our latest version to this list.
195
196
197
h2. Configuring Wt 
198
199
* Start cmake from the Start->CMake menu
200
* Where the source code is: c:\projects\witty\wt
201
* Where to build the binaries: c:\projects\witty\wt\build (or whatever)
202
* Click Configure
203
* Select Visual Studio 8 2005
204
205
You will probably get errors about OpenSSL not being found. Don't panic, we can disable it.
206
* Find HTTP_WITH_SSL and set it to 'OFF'
207
208
Press 'Configure' again. A few messages about the FCGI and wthttpd connector may pop up; click Ok. If all went well, you have now no red fields left and the configuration is complete. Press 'Ok' and your MSVC solution files will be generated.
209
210
211
212
h2. Compiling Wt 
213
214
Open the WT.sln solution in the 'Where to build the binaries' directory of the previous step. Press F7, or select the projects you want to build manually. You should not get any compile or link errors.
215
216
217
h2. Running the examples 
218
219
In the MSVC IDE Right-click on the example project you want to run, and select 'Properties'. In Configuration Properties->Debugging, set the Command Arguments to
220
221 10 Pieter Libin
 <pre>
222 1 Pieter Libin
--http-address=0.0.0.0 --http-port=8080 --deploy-path=/hello --docroot=.
223 10 Pieter Libin
 </pre>
224 1 Pieter Libin
225
The easiest way to locate the dependency dlls, is to append their location to the PATH variable. In order to do so, change the Environment field to contain a PATH directive:
226 10 Pieter Libin
 <pre>
227 1 Pieter Libin
PATH=c:/libraries/lib;c:/Boost/lib;<path to wt.dll>;<path to wthttp.dll>
228 10 Pieter Libin
 </pre>
229 1 Pieter Libin
230
Right-click on the example project you want to run and select 'Set as Startup Project'. Press F5 (Run). This will start a httpd server listening on all local interfaces, on port 8080, and you may browse the example at http://127.0.0.1:8080/hello
231
232
These are all the command-line options that are available:
233 10 Pieter Libin
 <pre>
234 1 Pieter Libin
General options:
235 10 Pieter Libin
 <pre>
236 1 Pieter Libin
  -h [ --help ]              produce help message
237
  -t [ --threads ] arg (=10) number of threads
238
  --docroot arg              document root for static files
239
  --no-compression           do not compress dynamic text/html and text/plain 
240
                             responses
241
  --deploy-path arg (=/)     location for deployment
242 10 Pieter Libin
 </pre>
243 1 Pieter Libin
244
HTTP server options:
245 10 Pieter Libin
 <pre>
246 1 Pieter Libin
  --http-address arg    IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
247
  --http-port arg (=80) HTTP port (e.g. 80)
248 10 Pieter Libin
 </pre>
249 1 Pieter Libin
250
HTTPS server options:
251 10 Pieter Libin
 <pre>
252 1 Pieter Libin
  --https-address arg     IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
253
  --https-port arg (=443) HTTPS port (e.g. 443)
254
  --ssl-certificate arg   SSL server certificate chain file
255
                          e.g. "/etc/ssl/certs/vsign1.pem"
256
  --ssl-private-key arg   SSL server private key file
257
                          e.g. "/etc/ssl/private/company.pem"
258
  --ssl-tmp-dh arg        File for temporary Diffie-Hellman parameters
259 10 Pieter Libin
                          e.g. "/etc/ssl/dh512.pem"
260
 </pre>