我開始學習如何編寫Wt應用程序,但我收到一個編譯錯誤,我不明白如何解決。編譯時,我收到一個錯誤,說Wt編譯問題
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
我運行Arch Linux的最新版本,如果這是任何用途。另外,這裏是我想要編譯的應用程序。
#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);
}
最新信息: 如果我鏈接libboost_signals libary,然後我收到以下控制檯輸出。
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