Postings by Michael on October 31, 2009
First of all, C++ for web apps doesn't necessarily make it easier to write them. Compared to other solutions (let's say Django) you'll end up writing a lot more code. And you have to be very very careful with memory leaks.
But that isn't the point. The main advantage of this framework is how close it is to desktop applications. Porting your Qt desktop application to the web is certainly easier with Wt than with any other solution, as you keep most of the widget API and also the signal and slots paradigm (which should allow to port the app reusing the same business logic as on the desktop).
Also, this is the first time I could attach a powerful debugger, namely gdb, to a web app and debug it is as if it were a normal desktop app. Together with the compiler-guaranteed type safety this is a huge improvement for code robustness.
A toolkit that actually uses C++
There are also some distinct advantages of this toolkit over Qt itself:
- no MOC preprocessing (unless you integrate it with your Qt libraries, of course),
- boost::signals & boost::bind wrapped in an easy-to-use WSignal, keeping most of the boost API accessible for the user. Which means: the compiler can check whether your signal connections will work!
- boost::any instead of QVariant: another big advantage. Boost::any is type-inferred using template voodoo so again, the compiler can check its correct usage for you. Getting values out sadly requires a (static) cast it seems.
- (enter your jhbuild shell if your project happens to use any GNOME stuff)
- enter the cloned git repo
- "$ mkdir build"
- "$ cd build #dont ignore this, it helps later on!"
- "$ cmake -i ../ #interactive mode asks lots of stupid things but also various path settings!"
- "$ make"
- "$ make install"
For your own projects make sure to link against all the needed Wt libs: libwt (core), libwtext (if you want to use anything from Wt::Ext, see below), libwthttp (if you want to build apps with inbuilt web server, quite helpful). If you happen to use autotools then you might want to include AC_CHECK_LIB macros into your configure.ac. I had troubles finding non-name-mangled function names, but "$ readelf --dynamic --symbols /path/to/lib/lib.so | grep -v _Z | tail" should help.
The installation instructions that come with Wt don't tell you how to install ExtJS, so here is what I found out:
- download ExtJS framework (you probably want version 3),
- copy it into your chosen wt webroot (let's say "/var/www/wt/"), consult your CMakeCache.txt,
- extract the zip archive,
- THEN copy /var/www/wt/ext/adapter/ext/ext-base.js to /var/www/wt/ext/ (the error message when starting the web server gave that hint away),
- make sure your project is linked against the libwtext library.