2007 Oct 03 - Wed
Installing And Configuring Wt, a C++ Web Toolkit
I mentioned in another article about doing web page development with C++. I came across
Wt: a C++ Web Toolkit. It has been
a bear to configure with the ASIO library. I'll layout what I've done below. I'm stuck
with an SSL initialization problem. I'm probably going to have to move to FastCGI to see
how well that works.
Based upon the forums, there are supposed to be some Debian Packages already available to
make this work. Packages seem to be a bit behind the latest versions of stuff, so in this
case, I wanted to be able to have a build system where I could incorporate the latest of
Boost (which is supposed to have time-series avaliable shortly), and with Wt (which has an
active CVS feed).
Anyway, here is my installation process so far. There are a couple of Kludges due to
platform differences (a prefix of lib is needed on some stuff, which I should do a SED with
at some time) and I can't figure out how the header file include stuff works properly (in
order to keep it in a separate directory).
I started by downloading
asio-0.3.7.tar.gz from asio.sf.net and boost_1_34_1.tar.tz from www.boost.org, and expanding
them out to their directories in /usr/src.
apt-get install gcc
apt-get install zlib1g
apt-get install zlib1g-dev
apt-get install libbz2-dev
apt-get install libgd-dev
apt-get install cmake
apt-get install libfcgi-dev
apt-get install libapache2-mod-fastcgi
apt-get install libssl-dev
cd /usr/src/boost_1_34_1
./configure --without-icu --without-libraries=python,wave,test --libdir=/usr/lib/boost_34_1
make install
ln -s /usr/lib/boost_1_34_1/ /usr/lib/boost
ln -s /usr/include/boost-1_34_1/boost /usr/include/boost
Before proceeding, a patch needs to be applied to one of the ASIO files:
@@ -45,13 +45,13 @@
{
::SSL_library_init();
::SSL_load_error_strings();
+ ::OpenSSL_add_ssl_algorithms();
mutexes_.resize(::CRYPTO_num_locks());
for (size_t i = 0; i < mutexes_.size(); ++i)
mutexes_[i].reset(new asio::detail::mutex);
::CRYPTO_set_locking_callback(&do_init::openssl_locking_func);
- ::OpenSSL_add_ssl_algorithms();
}
}
It basically moves the location of '::OpenSSL_add_ssl_algorithms();'. Without it, an
error such as the following may occur during runtime:
__gnu_cxx::recursive_init'
what(): N9__gnu_cxx14recursive_initE
Aborted
ASIO can then be built:
cd /usr/src/asio-0.3.7
./configure --with-boost=/usr/include/boost --libdir=/usr/lib/ --includedir=/usr/include/
make
make install
After that fixup, Wt can be built.
cd /usr/src
cvs -d:pserver:anonymous@witty.cvs.sourceforge.net:/cvsroot/witty login
cvs -z3 -d:pserver:anonymous@witty.cvs.sourceforge.net:/cvsroot/witty co -P wt
cd wt
nano src/CMakeLists.txt
# prefix boost file entries with lib to get libboost
cmake -D DEPLOYROOT=/var/www/wt -D WEBUSER=www-data -D WEBGROUP=www-data \
-D BOOST_DIR=/usr/include/boost/ \
-D BOOST_COMPILER=gcc41 \
-D BOOST_VERSION=1_34_1 \
-D BOOST_INCLUDE_DIR=/usr/include/boost \
-D BOOST_LIB_DIR=/usr/lib/boost/ \
-D BOOST_DT_LIB_MT=/usr/lib/boost \
-D BOOST_DT_LIB=/usr/lib/boost \
-D BOOST_FS_LIB=/usr/lib/boost \
-D BOOST_FS_LIB_MT=/usr/lib/boost \
-D BOOST_PO_LIB_MT=/usr/lib/boost \
-D BOOST_REGEX_LIB_MT=/usr/lib/boost \
-D BOOST_SIGNALS_LIB_MT=/usr/lib/boost \
-D BOOST_THREAD_LIB=/usr/lib/boost \
-D BOOST_ASIO_INCLUDE_DIR=/usr/include/asio/ \
-D CMAKE_INSTALL_PREFIX=/ \
-D LIB_INSTALL_DIR=/usr/lib/wt/ \
-D LIBRARY_OUTPUT_PATH=/usr/lib/wt \
-D SHARED_LIBS=ON \
-D CONNECTOR_FCGI=ON \
-D CONNECTOR_HTTP=OFF \
.
# FCGI ON for FastCGI (production), HTTP ON for ASIO library (development)
make
# on error:
nano src/Ext/cmake_install.cmake
# comment out cmakefiles line
rm /include/Ext/CMakeFiles
mkdir /include/Ext/CMakeFiles
cp /usr/src/wt/src/Ext/CMakeFiles/* /include/Ext/CMakeFiles
make install
mkdir /usr/include/wt
mv /include/* /usr/include/wt/
rmdir /include
nano /etc/ld.so.conf
# put in:
# /usr/lib/wt
# /usr/lib/boost_1_34_1
# ldconfig needs to be run if the fcgi or http libraries get switched or added
ldconfig
Back in Eclipse, I created C++ ANSI project, and then placed the content from
examples/hello/hello.cpp into the .cpp file of the new project. The directories
'/usr/include/boost-1_34_1' and '/usr/include/wt' need to be entered as 'include' paths.
For GCC C++ Linker, the following are -L library search paths:
- /usr/lib/wt
- /usr/lib/boost_1_34_1
The following are -l libraries:
- boost_signals-gcc41-mt-d
- boost_filesystem-gcc41-mt-d
- boost_program_options-gcc41-mt-d
- boost_thread-gcc41-mt-d
- boost_regex-gcc41-mt-d
- wt
- wthttp or wtfcgi
- wtext
So... with some recompiling, I was able to get the hello sample up and running with
FastCGI and then with the ASIO library.
When using FCGI, I renamed the compiled file to hello.wt, and
placed it into /var/www/wt/, added the line 'FastCgiServer /var/www/wt/hello.wt' into
/etc/apache2/mods-enabled/fastcgi.conf, and restarted Apache. Then by browsing to
localhost/wt/hello.wt, I was able to get the
demonstration.
When using ASIO, set the folloing for run-time command-line arguments in Eclipse to
successfully
start the application: '--doc-root=/var/www/wt --http-address=0.0.0.0 --http-port=8080'.
Browsing to localhost:8080 will get the web page.
|