Project

General

Profile

Installing Wt on MS Windows » History » Version 2

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