Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

(C++) Wt Wt

Wt (we pronounce that as 'witty') is a C++ library for developing interactive web applications [1].

Qt Creator Note for Qt Creator users

Add the following line to your Qt project file (to prevent link errors like undefined reference to 'Wt::WRun(int, char**, Wt::WApplication* (*)(Wt::WEnvironment const&))'):


LIBS += -lwt -lwthttp


For a Wt application to run, choose one of these options:


  1. Use my WtAutoConfig class:


    • Add the following line to your Qt project file:


      INCLUDEPATH += ../../Classes/CppWtAutoConfig


    • Change your main to the following, to let WtAutoConfig add the arguments:


      #include "wtautoconfig.h" int main(int argc, char **argv) {   WtAutoConfig a(argc,argv,createApplication);   return a.Run(); }


    I follow this approach in my larger programs.


  2. Change your main to the following, to call WRun with the arguments added with a C++11 initializer list:


    int main(int, char *argv[]) {   //C++11 initializer list   const char * const v[7] =   {     argv[0],     "--docroot", ".",     "--http-port", "8080",     "--http-address", ""   };   return WRun(7, const_cast<char**>(v), &CreateApplication); }


    I follow this approach my very small, mostly demonstrational, programs, for example in memcheck example 6.


  3. Add the following arguments to the Run Settings (to prevent the misc error stat: No such file or directory. Document root ("") not valid.


    --docroot . --http-address --http-port 8080


    Or to redirect the output to a log file (untested):


    --docroot . --http-address --http-port 8080 --accesslog access.log > /dev/null 2>&1 &


    I never follow this approach, because I prefer my solutions in code.







External links









  1. Wt homepage