Project

General

Profile

Installing Wt on MS Windows » History » Version 14

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

1 13 Pieter Libin
h1. Installing Wt 2.1 on MS Windows
2 1 Pieter Libin
3
{{toc}}
4
5 13 Pieter Libin
"【中文 Chinese 】":http://www.cookbus.com/wiki/index.php?title=%E5%AE%89%E8%A3%85_Wt_2.1_%E5%88%B0_MS_Windows#.E9.87.8D.E8.A6.81.E7.9A.84.E5.A4.87.E6.B3.A8
6 1 Pieter Libin
7
8 13 Pieter Libin
This HOWTO assumes you have a clean Windows system and want to use Wt 2.1 or newer series (users of older versions can go to [[Installing Wt on MS Windows]]). 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.
9 1 Pieter Libin
10 13 Pieter Libin
Unlike Linux distributions, Windows has no easy package managers for developers. To avoid that you're compiling dependencies for half a day before you can use Wt, we strongly reduced the minimal dependencies that Wt requires. Since Wt 2.1, Boost and cmake are the only required dependencies. We will explain two approaches to set up your environment: the quick method, using binary packages, and the thorough method, in which you compile more dependencies, but which will also result in a Wt that supports compression, SSL, etc.
11 1 Pieter Libin
12 13 Pieter Libin
These instructions have been tested both on Windows XP and Windows Vista. These instructions are valid for all 2.1 and newer versions of Wt.
13 1 Pieter Libin
14
15
h2. Setting up your compiler 
16
17 13 Pieter Libin
You need either Microsoft Visual Studio 2005 or 2008 Professional or Microsoft Visual Studio 2005 or 2008 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.
18 1 Pieter Libin
19
For more information about the compiler, see [[Installing MSVC 2005]].
20
21
22 13 Pieter Libin
h2. The Quick Method 
23 1 Pieter Libin
24 13 Pieter Libin
The quick method installs Wt without any optional components (compression-over-HTTP and support for HTTPS)
25 1 Pieter Libin
26
27 13 Pieter Libin
h3. Download Dependencies 
28 1 Pieter Libin
29 13 Pieter Libin
* Download the BoostPro installer for version 1.35 or newer from "boost-consulting":http://www.boost-consulting.com/products/free (you might need to register in order to download the BoostPro installer). Run it, and install all types for all libraries for the correct version of your MSVC compiler at a location of your choice. Asio, which used to be a dependency, is included in boost versions 1.35 and newer and does no longer need to be installed separately.
30
* Download the "cmake 2.6":http://www.cmake.org/ (cmake > 2.4.6 required) Windows Installer. Run the installer to install cmake.
31
* Download Wt from the "download page":http://www.webtoolkit.eu/wt/#example:0;main:6. Unzip it somehwere (c:/projects/witty/wt-2.x.x).
32 1 Pieter Libin
33
34 13 Pieter Libin
h3. Configuring Wt 
35 1 Pieter Libin
36 13 Pieter Libin
* Start cmake from the Start->CMake menu
37
* Where the source code is: c:\projects\witty\wt-2.x.x
38
* Where to build the binaries: c:\projects\witty\wt-2.x.x\build (or whatever)
39
* Click Configure
40
* Select Visual Studio 8 2005 or 2008
41 1 Pieter Libin
42 13 Pieter Libin
You will probably get errors about Boost not being found. That is normal, as you did not yet tell where the library is located. Set this variables:
43
* BOOST_DIR = c:/Program Files/boost/boost_1_35_0
44 1 Pieter Libin
45 13 Pieter Libin
Press 'Configure' again. A few messages about the FCGI and wthttpd connector may pop up; click Ok. A few new configuration fields (in red) will have popped up; leave them unchanged and press 'Configure' once more. 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.
46 1 Pieter Libin
47
48
49 13 Pieter Libin
h3. Compiling Wt 
50 1 Pieter Libin
51 13 Pieter Libin
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.
52 1 Pieter Libin
53
54 13 Pieter Libin
h3. Running the examples 
55 1 Pieter Libin
56 13 Pieter Libin
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
57 1 Pieter Libin
58 13 Pieter Libin
 <pre>
59
--http-address=0.0.0.0 --http-port=8080 --deploy-path=/hello --docroot=.
60 1 Pieter Libin
 </pre>
61
62 13 Pieter Libin
Wt builds static versions of all libraries by default and links against static boost libraries by default. If you would choose to build dynamic libraries in the future (see remarks at the bottom of this page), 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:
63
 <pre>
64
PATH=c:/libraries/lib;c:/Boost/lib;<path to wt.dll>;<path to wthttp.dll>
65
 </pre>
66 1 Pieter Libin
67 13 Pieter Libin
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
68 1 Pieter Libin
69 13 Pieter Libin
Examples that need extra files to run, should be executed from their source directory in order to find their dependency files (icons, css files, etc. Watch for 404 errors in Wt's output). To do so, set the 'Working directory' for the example to wt-2.x.x/examples/ExampleName. Some examples (e.g. the wt home page) need the 'resources' directory to work correctly. Copy the wt-2.x.x/resources to the example's source directory to solve this problem. Other examples (such as the Charts example) may require the installation of ExtJs. See the Wt reference manual for more information on how to obtain and install ExtJs.
70 1 Pieter Libin
71 13 Pieter Libin
These are all the command-line options that are available:
72
 <pre>
73
General options:
74
  -h [ --help ]              produce help message
75
  -t [ --threads ] arg (=10) number of threads
76
  --docroot arg              document root for static files
77
  --no-compression           do not compress dynamic text/html and text/plain 
78
                             responses
79
  --deploy-path arg (=/)     location for deployment
80 1 Pieter Libin
81 13 Pieter Libin
HTTP server options:
82
  --http-address arg    IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
83
  --http-port arg (=80) HTTP port (e.g. 80)
84 1 Pieter Libin
85 13 Pieter Libin
HTTPS server options:
86
  --https-address arg     IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
87
  --https-port arg (=443) HTTPS port (e.g. 443)
88
  --ssl-certificate arg   SSL server certificate chain file
89
                          e.g. "/etc/ssl/certs/vsign1.pem"
90
  --ssl-private-key arg   SSL server private key file
91
                          e.g. "/etc/ssl/private/company.pem"
92
  --ssl-tmp-dh arg        File for temporary Diffie-Hellman parameters
93
                          e.g. "/etc/ssl/dh512.pem"
94
 </pre>
95 1 Pieter Libin
96
97
98 13 Pieter Libin
h3. Installing Wt 
99 1 Pieter Libin
100 13 Pieter Libin
After compilation, right-click on 'INSTALL' and select 'build'. This will copy Wt header files an libraries to c:/Program Files/WT.
101 1 Pieter Libin
102
103
104 13 Pieter Libin
h2. Optional components 
105
106
This involves installing SSL, zlib, and some other components. After installation as described here, rerun cmake so that it uses. These instructions are valid for Wt > 2.1.0.
107
108
109
h3. Preparations 
110
111
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'.
112 1 Pieter Libin
 <pre>
113 13 Pieter Libin
mkdir c:\libraries
114
mkdir c:\libraries\lib
115
mkdir c:\libraries\include
116 1 Pieter Libin
 </pre>
117
118
119 13 Pieter Libin
h3. Download and build zlib 
120 1 Pieter Libin
121 13 Pieter Libin
Zlib is an optional dependency of Wt, which can be controlled by the CMake flag HTTP_WITH_ZLIB. With zlib, Wt compresses all http traffic by default, saving bandwidth.
122 1 Pieter Libin
123 13 Pieter Libin
* Get zlib from http://www.zlib.net/ ("direct link for version 1.2.3":http://www.gzip.org/zlib/zlib-1.2.3.tar.gz). 
124 1 Pieter Libin
* Open zlib-1.2.3\contrib\vstudio\vc8\zlibvc.sln
125 13 Pieter Libin
* Select solution 'Debug', architecture 'Win32' (in the toolbar)
126
* Right-click on project 'zlibstat', select Properties. In 'Configuration Properties'->'C/C++'->'Code Generation'->'Runtime Libraries' and set it to 'Multi-threaded Debug DLL (/MDd)'. Close the properties window.
127
* Do the same with project 'zlibvc'
128
* Right-click on project 'zlibstat', and select 'Build' to build it.
129
* Select solution 'Release', architecture 'Win32' 
130
* Right-click on project 'zlibstat', select Properties. In 'Configuration Properties'->'C/C++'->'Code Generation'->'Runtime Libraries' and set it to 'Multi-threaded DLL (/MD)'. Close the properties window.
131
* Do the same with project 'zlibvc'* Right-click on project 'zlibstat', and select 'Build' to build it.
132 10 Pieter Libin
133 13 Pieter Libin
Results are now located in the x86 directory. Copy them into our central repository location, renaming the debug library in the process:
134 1 Pieter Libin
 <pre>
135
cp contrib\vstudio\vc8\x86\ZlibStatDebug\zlibstat.lib c:\libraries\lib\zlibstatd.lib
136
cp contrib\vstudio\vc8\x86\ZlibStatRelease\zlibstat.lib c:\libraries\lib\
137 10 Pieter Libin
 </pre>
138 1 Pieter Libin
139
We also need zlib.h and zconf.h header files.
140
 <pre>
141
cp zlib.h zconf.h c:\libraries\include
142
 </pre>
143
144
145 13 Pieter Libin
h3. OpenSSL 
146 1 Pieter Libin
147 13 Pieter Libin
You need OpenSSL if you want to use Wt to support https mode. Grab a pre-compiled binary from http://www.openssl.org/related/binaries.html, install it in the default path (c:\OpenSSL) and Wt's CMake files will find and use OpenSSL (verify that HTTP_WITH_SSL is enabled).
148 1 Pieter Libin
149
150 13 Pieter Libin
h2. Important Remarks 
151 1 Pieter Libin
152 13 Pieter Libin
By default, Wt will build static libraries that are statically linked against boost. While this is convenient for quick deployment (the example binaries do not require dlls to run, so you do not have to set their PATHs correctly), many people prefer to use dll's, not in the least because your Wt applications will link much faster.
153 1 Pieter Libin
154 13 Pieter Libin
Two cmake options control how Wt is built, and what kind of boost libraries it uses:
155
* BOOST_DYNAMIC: set to true to build against boost dlls. Set to false to link to static boost libraries.
156
* SHARED_LIBS: set to true to build a Wt DLL, set to false to build a static Wt library.
157 1 Pieter Libin
158 13 Pieter Libin
When you double-checked the library directories but you still get build errors such as "cannot open file 'libboost_signals-vc90-mt-gd-1_35.lib'", you probably did not install or build the static boost files, while the BOOST_DYNAMIC option is set to false. Similarly, when the error indicates that boost_signals-vc90-mt-gd-1_35.lib is not found, you probably haven't installed or built the boost dlls, while BOOST_DYNAMIC is set to true.
159 10 Pieter Libin
160 13 Pieter Libin
Note that, when you build a static Wt library (SHARED_LIBS is false), you will get these boost-related linker errors only when you compile the examples.