Search code examples
c++compilationcompiler-errorswt

Wt Compilation Issues


I am beginning to learn how to write Wt applications, but I am receiving a compilation error which I do not understand how to fix. When compiling, I receive an error that says

g++ -lwthttp -lwt hello.cpp
/usr/bin/ld: /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to symbol '_ZN5boost7signals6detail16signal_base_impl12connect_slotERKNS_3anyERKNS1_12stored_groupENS_10shared_ptrINS1_9slot_base6data_tEEENS0_16connect_positionE'
/usr/bin/ld: note: '_ZN5boost7signals6detail16signal_base_impl12connect_slotERKNS_3anyERKNS1_12stored_groupENS_10shared_ptrINS1_9slot_base6data_tEEENS0_16connect_positionE' is defined in DSO /usr/lib/libboost_signals.so.1.52.0 so try adding it to the linker command line
/usr/lib/libboost_signals.so.1.52.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

I am running the most recent version of Arch Linux, if that is of any use. Also, here is the application that I want to compile.

#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>

class HelloApplication : public Wt::WApplication {
  public:
    HelloApplication(const Wt::WEnvironment& env);

  private:
    Wt::WLineEdit *nameEdit_;
    Wt::WText     *greeting_;

    void greet();
};

HelloApplication::HelloApplication(const Wt::WEnvironment& env) : Wt::WApplication(env) {
  setTitle("Hello world");

  root()->addWidget(new Wt::WText("What is your name? "));
  nameEdit_ = new Wt::WLineEdit(root());
  Wt::WPushButton *button = new Wt::WPushButton("Greet me.", root());
  root()->addWidget(new Wt::WBreak());
  greeting_ = new Wt::WText(root());
  button->clicked().connect(this, &HelloApplication::greet);
}

void HelloApplication::greet() {
  greeting_->setText("Hello there, " + nameEdit_->text());
}

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

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

UPDATED INFORMATION: If I link the libboost_signals libary, then I receive the following console output.

    g++ hello.cpp -lwt -lwthttp -lboost_signals

/usr/bin/ld: warning: libGraphicsMagick.so.3, needed by /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathCurveToQuadraticBezierAbsolute'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetStrokeWidth'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetClipUnits'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `SetImageType'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetStrokeColor'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `GetDrawInfo'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawDestroyContext'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathLineToAbsolute'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawAnnotation'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `ReadInlineImage'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathStart'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetClipPath'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `SetImagePixels'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetStrokeOpacity'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPopClipPath'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetFillOpacity'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetStrokeAntialias'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPopGraphicContext'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `SyncImagePixels'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DestroyImage'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPushGraphicContext'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawLine'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawRender'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DestroyMagick'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathCurveToAbsolute'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `ConstituteImage'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetFontSize'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `GetExceptionInfo'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `GetImagePixels'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetStrokeDashArray'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `ImageToBlob'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `ReadImage'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `SetImageOpacity'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathMoveToAbsolute'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPushClipPath'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `CropImage'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetFillRule'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathFinish'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `GetImageInfo'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetFillColor'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetFont'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawArc'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawAffine'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DestroyDrawInfo'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawClipPath'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetTextEncoding'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `SetImageClipMask'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawComposite'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawPathEllipticArcAbsolute'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawAllocateContext'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetStrokeLineCap'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `InitializeMagick'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `DrawSetGravity'
/usr/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../libwt.so: undefined reference to `CompositeImage'
collect2: error: ld returned 1 exit status

Solution

  • It turns out that there are some optional dependencies listed on the AUR which are required for proper compilation. They are listed here

    https://www.archlinux.org/packages/community/i686/wt/
    

    Also, when following the tutorial found here

    http://www.webtoolkit.eu/wt/src/hello
    

    You must include the

    -lboost_signals
    

    flag while compiling.