gpt4 book ai didi

c++ - Wt 编译问题

转载 作者:行者123 更新时间:2023-11-28 03:20:23 26 4
gpt4 key购买 nike

我开始学习如何编写 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com