Project

General

Profile

Installing Wt on MS Windows » History » Version 36

Wim Dumon, 08/11/2011 05:30 PM

1 15 Pieter Libin
h1. Installing Wt on MS Windows
2 1 Pieter Libin
3
{{toc}}
4
5 16 Wim Dumon
This HOWTO assumes you have a clean Windows system and want to use Wt 2.1 or newer series. 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 1 Pieter Libin
7 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.
8 1 Pieter Libin
9 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.
10 1 Pieter Libin
11
12
h2. Setting up your compiler 
13
14 16 Wim Dumon
You need Microsoft Visual Studio 2005 or newer, Professional or 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.
15 1 Pieter Libin
16 16 Wim Dumon
For more information about the compiler, see [[Installing MSVC]].
17 1 Pieter Libin
18 34 Wim Dumon
Note for MSVC 2010 SP1 users: "FIX: Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed":http://support.microsoft.com/?kbid=2519277
19
20 1 Pieter Libin
21 13 Pieter Libin
h2. The Quick Method 
22 1 Pieter Libin
23 13 Pieter Libin
The quick method installs Wt without any optional components (compression-over-HTTP and support for HTTPS)
24 1 Pieter Libin
25
26 13 Pieter Libin
h3. Download Dependencies 
27 1 Pieter Libin
28 36 Wim Dumon
* Install Boost. Either download binaries from BoostPro, or compile your own:
29
> * Download the BoostPro installer for version 1.36 or newer (there are problems with boost 1.46 and 1.47 with Wt < 3.1.11) from "boost-consulting":http://www.boost-consulting.com/download/ (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.
30
> * To compile boost yourself, download the boost sources from boost.org. Boost has a tendancy to frequently change its installation instructions, but since a while it has been:
31
<pre>
32
bootstrap
33
bjam --layout=versioned --toolset=msvc-10.0 variant=debug threading=multi link=static runtime-link=shared install
34
bjam --layout=versioned --toolset=msvc-10.0 variant=release threading=multi link=static runtime-link=shared install
35
</pre>
36 35 Wim Dumon
* Download the "cmake 2.8":http://www.cmake.org/ (cmake > 2.4.6 required) Windows Installer. Run the installer to install cmake.
37
* Download Wt from the "download page":http://www.webtoolkit.eu/wt/download. Unzip it somehwere (c:/projects/witty/wt-3.x.x).
38 1 Pieter Libin
39
40 13 Pieter Libin
h3. Configuring Wt 
41
42 35 Wim Dumon
* Start cmake from the Start->CMake menu
43
* Where the source code is: c:\projects\witty\wt-3.x.x
44 13 Pieter Libin
* Where to build the binaries: c:\projects\witty\wt-3.x.x\build (or whatever, but choose something different than the source directory)
45 35 Wim Dumon
* Click Configure
46 1 Pieter Libin
* Select Visual Studio 2005 or 2008 or 2010
47
48 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:
49 36 Wim Dumon
* BOOST_DIR = c:/Program Files/boost/boost_1_36_0 (adapt for your version; just c:/Boost if you compiled boost yourself)
50 1 Pieter Libin
51 18 Anonymous
Another error you might encounter in CMake is "The C compiler "cl" is not able to compile a simple test program." This means that your Visual Studio won't find 'cmd' as it isn't configured correctly.
52
53
What you must do is change MSVS options (Tools menu > Options > Project and Solutions > VC++ Directories) to ensure that
54
55
*    $(SystemRoot)
56
57
*    $(SystemRoot)\System32
58
59
*    $(SystemRoot)\System32\wbem
60
61
*    are specified BEFORE $(PATH).
62
63
64 35 Wim Dumon
Press 'Configure' again. A few messages about the FCGI and wthttpd connector may pop up; just 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 Generate (in cmake <2.8, this button is called 'Ok') and your MSVC solution files will be generated.
65 1 Pieter Libin
66
67
68 13 Pieter Libin
h3. Compiling Wt 
69 1 Pieter Libin
70 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.
71 1 Pieter Libin
72
73 13 Pieter Libin
h3. Running the examples 
74 1 Pieter Libin
75 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
76 1 Pieter Libin
77 13 Pieter Libin
 <pre>
78
--http-address=0.0.0.0 --http-port=8080 --deploy-path=/hello --docroot=.
79 1 Pieter Libin
 </pre>
80
81 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:
82
 <pre>
83
PATH=c:/libraries/lib;c:/Boost/lib;<path to wt.dll>;<path to wthttp.dll>
84
 </pre>
85 1 Pieter Libin
86 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
87 1 Pieter Libin
88 23 Koen Deforche
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.
89 1 Pieter Libin
90 35 Wim Dumon
These are all the command-line options that are available (run the wt application with --help to see the newer options available in your version):
91 13 Pieter Libin
 <pre>
92
General options:
93
  -h [ --help ]              produce help message
94
  -t [ --threads ] arg (=10) number of threads
95
  --docroot arg              document root for static files
96
  --no-compression           do not compress dynamic text/html and text/plain 
97
                             responses
98
  --deploy-path arg (=/)     location for deployment
99 1 Pieter Libin
100 13 Pieter Libin
HTTP server options:
101
  --http-address arg    IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
102
  --http-port arg (=80) HTTP port (e.g. 80)
103 1 Pieter Libin
104 13 Pieter Libin
HTTPS server options:
105
  --https-address arg     IPv4 (e.g. 0.0.0.0) or IPv6 Address (e.g. 0::0)
106
  --https-port arg (=443) HTTPS port (e.g. 443)
107
  --ssl-certificate arg   SSL server certificate chain file
108
                          e.g. "/etc/ssl/certs/vsign1.pem"
109
  --ssl-private-key arg   SSL server private key file
110
                          e.g. "/etc/ssl/private/company.pem"
111
  --ssl-tmp-dh arg        File for temporary Diffie-Hellman parameters
112
                          e.g. "/etc/ssl/dh512.pem"
113
 </pre>
114 1 Pieter Libin
115
116
117 13 Pieter Libin
h3. Installing Wt 
118 1 Pieter Libin
119 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.
120 1 Pieter Libin
121
122
123 13 Pieter Libin
h2. Optional components 
124
125
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.
126
127
128
h3. Preparations 
129
130
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'.
131 1 Pieter Libin
 <pre>
132 13 Pieter Libin
mkdir c:\libraries
133
mkdir c:\libraries\lib
134
mkdir c:\libraries\include
135 1 Pieter Libin
 </pre>
136
137
138 13 Pieter Libin
h3. Download and build zlib 
139 1 Pieter Libin
140 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.
141 1 Pieter Libin
142 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). 
143 1 Pieter Libin
* Open zlib-1.2.3\contrib\vstudio\vc8\zlibvc.sln
144 13 Pieter Libin
* Select solution 'Debug', architecture 'Win32' (in the toolbar)
145
* 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.
146
* Do the same with project 'zlibvc'
147
* Right-click on project 'zlibstat', and select 'Build' to build it.
148
* Select solution 'Release', architecture 'Win32' 
149
* 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.
150
* Do the same with project 'zlibvc'* Right-click on project 'zlibstat', and select 'Build' to build it.
151 10 Pieter Libin
152 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:
153 1 Pieter Libin
 <pre>
154
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
 <pre>
160
cp zlib.h zconf.h c:\libraries\include
161
 </pre>
162
163
164 13 Pieter Libin
h3. OpenSSL 
165 1 Pieter Libin
166 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).
167 1 Pieter Libin
168 26 Wim Dumon
h3. GraphicsMagick
169
170
Generic build instructions for GraphicsMagick are found here: http://www.graphicsmagick.org/INSTALL-windows.html#installing-from-source-code
171
172
In order for GraphicsMagick to work with your version of MSVC, it is strongly recommended to build it from the sources. Follow the instructions on the GraphicsMagick site:
173
* Run @VisualMagick/configure/configure.exe@ to create a .sln file
174
* Make sure to select the default 'Dynamic Multi-threaded DLL runtimes' and 'Use X11 stubs to prevent use of X windows'
175
* Open @VisualMagick/VisualStaticMT.sln@ in MSVC and press F7. Make sure you select the 'Release' or 'Debug' build as appropriate. For me, the UTIL_IMDisplay project fails to compile, which is unimportant.
176
177
While configuring Wt, point GM_PREFIX to the toplevel directory of GraphicsMagick (i.e. the one containing subdirectories VisualMagick and magick). Press Configure, and cmake should find the header files and compiled binaries.
178
179
Important: when executing a binary linked to a Wt library that uses GraphicsMagick, the GraphicsMagick DLLs must be found by Windows. This means that they should  be in c:/windows/system32, or in the current working directory, or that you should add the VisualMagick/bin directory to your path. Otherwise your application will complain that it cannot find the required DLLs to start up.
180 1 Pieter Libin
181 27 Wim Dumon
In order to render fonts, verify that your imagemagick fonts are correctly configured. For example, on my computer I had to remove the include for type-ghostscript.mgk in the VisualMagick/bin/type.mgk file to have any fonts rendered at all.
182
183 13 Pieter Libin
h2. Important Remarks 
184 1 Pieter Libin
185 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.
186 1 Pieter Libin
187 13 Pieter Libin
Two cmake options control how Wt is built, and what kind of boost libraries it uses:
188
* BOOST_DYNAMIC: set to true to build against boost dlls. Set to false to link to static boost libraries.
189
* SHARED_LIBS: set to true to build a Wt DLL, set to false to build a static Wt library.
190 1 Pieter Libin
191 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.
192 10 Pieter Libin
193 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.
194 25 Wim Dumon
195
h2. Support for Microsoft IIS
196
197
Wt works well with Microsoft IIS as ISAPI extensions. See the [[ISAPI on Microsoft IIS]] wiki for more information on how to deploy Wt in IIS.