(C++) Wt
January 18, 2018 · View on GitHub
Wt (we pronounce that as 'witty') is a C++ library for developing interactive web applications [1].
- 'Hello Wt' program
- Wt articles
- Wt and assert
- Wt classes
- Wt deployment
- Wt examples
- Wt FAQ
- Wt with other libraries
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:
-
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.
-
-
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.
-
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 8080Or 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