Project

General

Profile

Installing Wt 21 on MS Windows » History » Version 2

Pieter Libin, 10/29/2009 01:16 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 2 Pieter Libin
*Wt version 2.1.x has its own installation instructions: [[Installing Wt 2.1 on MS Windows]]*
8 1 Pieter Libin
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 2 Pieter Libin
*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.*
14 1 Pieter Libin
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
<pre>
30
mkdir c:\libraries
31
mkdir c:\libraries\lib
32
mkdir c:\libraries\include
33
</pre>
34
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
* 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
<pre>
51
bjam "-sTOOLS=vc-8_0" "--prefix=c:\libraries" install
52
</pre>
53
* Ignore messages about python and others
54
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
<pre>
66
bjam --toolset=msvc-8.0 --prefix=c:\libraries install
67
</pre>
68
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
<pre>
76
--- ./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
<pre>
80
       {
81
         ::SSL_library_init();
82
         ::SSL_load_error_strings();        
83
</pre>
84
+        ::OpenSSL_add_ssl_algorithms();
85
<pre>
86
 
87
         mutexes_.resize(::CRYPTO_num_locks());
88
         for (size_t i = 0; i < mutexes_.size(); ++i)
89
           mutexes_[i].reset(new asio::detail::mutex);
90
         ::CRYPTO_set_locking_callback(&do_init::openssl_locking_func);
91
 
92
</pre>
93
-        ::OpenSSL_add_ssl_algorithms();
94
<pre>
95
       }
96
     }
97
</pre>
98
99
</pre>
100
101
Boost asio is a headerfile-only library, so no compilation is required.
102
103
104
h3. MXML 
105
106
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.
107
108
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.
109
* Download "Mini-XML":http://www.minixml.org/ (mxml-2.3.tar.gz)
110
* Apply the following patch to avoid compile errors:
111
<pre>
112
--- mxml-2.3-orig/mxml-string.c 2007-04-18 15:14:10.000000000 +0200
113
+++ mxml-2.3/mxml-string.c      2007-07-07 14:59:58.697309500 +0200
114
@@ -30,6 +30,7 @@
115
116
<pre>
117
 #include "config.h"
118
</pre>
119
120
+char *_mxml_vstrdupf(const char *format, va_list ap);
121
122
<pre>
123
 #ifdef HAVE_SNPRINTF
124
 /*
125
</pre>
126
127
</pre>
128
<pre>
129
--- mxml-2.3-orig/vcnet/config.h        2007-04-18 15:14:10.000000000 +0200
130
+++ mxml-2.3/vcnet/config.h     2007-07-07 18:01:18.009809500 +0200
131
@@ -48,9 +48,9 @@
132
<pre>
133
 /*
134
  * Do we have the snprintf() and vsnprintf() functions?
135
  */
136
</pre>
137
-
138
-/*#undef HAVE_SNPRINTF */
139
-/*#undef HAVE_VSNPRINTF */
140
+#define snprintf _snprintf
141
+#define HAVE_SNPRINTF 1
142
+#define HAVE_VSNPRINTF 1
143
144
145
<pre>
146
 /*
147
</pre>
148
149
</pre>
150
* Open the solution mxml-2.3\vcnet\mxml.sln. Convert the solution to a 2005 solution by clicking 'Finish'.
151
* 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.
152
153
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:
154
<pre>
155
cp mxml.h c:\libraries\include
156
cp *.lib c:\libraries\lib
157
</pre>
158
159
160
161
h3. zlib 
162
163
* Download "zlib":http://www.zlib.net/zlib-1.2.3.tar.gz
164
* Open zlib-1.2.3\contrib\vstudio\vc8\zlibvc.sln
165
* Select solution 'Debug', architecture 'Win32' and press F7 (Build all)
166
* Select solution 'Release', architecture 'Win32' and press F7 (Build all)
167
168
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:
169
<pre>
170
cp contrib\vstudio\vc8\x86\ZlibStatDebug\zlibstat.lib c:\libraries\lib\zlibstatd.lib
171
cp contrib\vstudio\vc8\x86\ZlibStatRelease\zlibstat.lib c:\libraries\lib\
172
</pre>
173
174
We also need zlib.h and zconf.h header files.
175
<pre>
176
cp zlib.h zconf.h c:\libraries\include
177
</pre>
178
179
h3. cmake 
180
181
* Download the Win32 Installer (cmake-2.4.6-win32-x86.exe) from http://www.cmake.org/
182
* Run the installer
183
184
CMake is now ready for use.
185
186
187
h3. OpenSSL (optional) 
188
189
OpenSSL is used by the wthttpd connector to support encrypted links over http (SSL). The compilation of the OpenSSL library will be covered later.
190
191
192
h3. libgd (optional) 
193
194
195
h3. libmysql (optional) 
196
197
198
h3. libmysql++ (optional) 
199
200
201
h3. cygwin (optional) 
202
203
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.
204
205
206
h2. Download Wt 
207
208
The following versions of Wt are known to compile according to the instructions of this HOWTO:
209
* None
210
Feel free to report success here if we forgot to add our latest version to this list.
211
212
213
h2. Configuring Wt 
214
215
* Start cmake from the Start->CMake menu
216
* Where the source code is: c:\projects\witty\wt
217
* Where to build the binaries: c:\projects\witty\wt\build (or whatever)
218
* Click Configure
219
* Select Visual Studio 8 2005
220
221
You will probably get errors about OpenSSL not being found. Don't panic, we can disable it.
222
* Find HTTP_WITH_SSL and set it to 'OFF'
223
224
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.
225
226
227
228
h2. Compiling Wt 
229
230
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.
231
232
233
h2. Running the examples 
234
235
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
236
237
<pre>
238
--http-address=0.0.0.0 --http-port=8080 --deploy-path=/hello --docroot=.
239
</pre>
240
241
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:
242
<pre>
243
PATH=c:/libraries/lib;c:/Boost/lib;<path to wt.dll>;<path to wthttp.dll>
244
</pre>
245
246
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
247
248
These are all the command-line options that are available:
249
<pre>
250
General options:
251
<pre>
252
  -h [ --help ]              produce help message
253
  -t [ --threads ] arg (=10) number of threads
254
  --docroot arg              document root for static files
255
  --no-compression           do not compress dynamic text/html and text/plain 
256
                             responses
257
  --deploy-path arg (=/)     location for deployment
258
</pre>
259
260
HTTP server options:
261
<pre>
262
  --http-address arg    IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
263
  --http-port arg (=80) HTTP port (e.g. 80)
264
</pre>
265
266
HTTPS server options:
267
<pre>
268
  --https-address arg     IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
269
  --https-port arg (=443) HTTPS port (e.g. 443)
270
  --ssl-certificate arg   SSL server certificate chain file
271
                          e.g. "/etc/ssl/certs/vsign1.pem"
272
  --ssl-private-key arg   SSL server private key file
273
                          e.g. "/etc/ssl/private/company.pem"
274
  --ssl-tmp-dh arg        File for temporary Diffie-Hellman parameters
275
                          e.g. "/etc/ssl/dh512.pem"
276
</pre>
277
</pre>