Search code examples
c++wt

Wt C++ root() Returns Null


I have installed Wt 3.3.1 binary to Windows 10 and using it with VS2015. I have also boost 1.53 installed. Everytime I try to run the following example, the root() function always returns 0xFFFFFFFF and I can make nothing with root():

WebApplication.cpp:

#include "stdafx.h"
#include "application.h"

HelloApplication::HelloApplication(const WEnvironment& env)
    : WApplication(env)
{
    setTitle("Hello world");
    root()->addWidget(new WText("Hey guys, welcome back!"));
}

WApplication *createApplication(const WEnvironment& env)
{
    return new HelloApplication(env);
}

application.h:

#include "stdafx.h"
#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WServer>
#include <Wt/WException>

// c++0x only, for std::bind
// #include <functional>

using namespace Wt;

/*
* A simple hello world application class which demonstrates how to react
* to events, read input, and give feed-back.
*/
class HelloApplication : public WApplication
{
public:
    HelloApplication(const WEnvironment& env);

private:
};

WApplication *createApplication(const WEnvironment& env);

application.cpp:

#include "stdafx.h"
#include "application.h"

int main(int argc, char **argv)
{
    return WRun(argc, argv, &createApplication);
}

It works when I do not use root() , for example when I leave setTitle("...") alone without having root()-addWidget(...) it works, sets the page title but when a line with root() comes, it crashes with a message saying: "widgetRoot was 0xFFFFFFFF". Can anyone please help? Thanks


Solution

  • Okay, I could not find a solution with pre-built libraries. My solution was to download Wt source, Boost and compile them with CMake. It still does not work in Debug mode but I have at least one working version (release) now.