c++ - Wt 编译问题

标签 c++ compilation compiler-errors 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 库,那么我会收到以下控制台输出。

    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

最佳答案

事实证明,AUR 上列出了一些可选的依赖项,这些依赖项是正确编译所必需的。它们列在这里

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

此外,当按照此处找到的教程进行操作时

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

你必须包括

-lboost_signals

编译时标记。

关于c++ - Wt 编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15603899/

相关文章:

c++ - cudaMemCpy2D() 的堆内存上具有连续行的二维数组

c++ - GCC -flto 更改符号可见性

java - 使用 HashMap 比较两个字谜时出现编译错误

C++20 概念语法 - requires 参数变量是什么意思?

c++ - libpng 在 png_write_into 上崩溃(Windows 10,VS2013,自建,所有测试通过 ok)

Java: float, long 局部初始化

c - 使用GCC编译C代码

compiler-errors - 如何编译以下 Rust 代码?

c++ - 如何在重命名函数(c++)中使用变量?

scala - Scala本地类型推断下划线表示法