Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
160 lines (99 sloc) 4.89 KB

(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", "0.0.0.0"   };   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 0.0.0.0 --http-port 8080

     

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

     


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

     

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

     

 

 

 

 

 

External links

 

 

 

 

 

 

References

 

  1. Wt homepage

 

 

 

 

 

 

You can’t perform that action at this time.