严重错误:Wt / WApplication.h:没有此类文件或目录

时间:2018-11-06 20:59:58

标签: c++ raspberry-pi wt

我正在跟着本Webtoolkit教程:https://www.webtoolkit.eu/wt/doc/tutorial/wt.html

我正在虚拟机上的Rasbian / Debian上运行所有这些程序,并且正在使用C ++ 14

我决定将hello.cpp代码复制粘贴到我的桌面上,并在终端上像这样编译它,因为我面临链接错误,因此在教程中跟随命令行示例:

g++ -std=c++14 -o hello hello.cpp -I/usr/include -L/usr/lib

但是我仍然得到:

hello.cpp:1:29: fatal error: Wt/WApplication.h: No such file or directory
 #include <Wt/WApplication.h>

我的Wt文件位于/ usr / include和/ usr / lib中,这就是我使用它们的原因。

此stackoverflow无法解决我的问题:How to Install Wt into a Custom Folder Without "fatal error: Wt/WApplication: No such file or directory"

编辑:我能够运行/ usr / lib / Wt / examples中Wt文件夹中的示例文件,但无法在桌面上运行,我按照教程中的命令行示例链接错误

编辑2:如果有帮助,请使用cpp代码,与教程相同,只需复制粘贴即可:

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

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

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

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

    root()->addWidget(std::make_unique<Wt::WText>("Your name, please? "));
    nameEdit_ = root()->addWidget(std::make_unique<Wt::WLineEdit>());
    Wt::WPushButton *button = root()->addWidget(std::make_unique<Wt::WPushButton>("Greet me."));
    root()->addWidget(std::make_unique<Wt::WBreak>());
    greeting_ = root()->addWidget(std::make_unique<Wt::WText>());
    auto greet = [this]{
      greeting_->setText("Hello there, " + nameEdit_->text());
    };
    button->clicked().connect(greet);
}

int main(int argc, char **argv)
{
    return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
      return std::make_unique<HelloApplication>(env);
    });
}

3 个答案:

答案 0 :(得分:0)

Wt包含文件在某些​​操作系统上不具有.h扩展名。 尝试while True: collectEyesBlade = raw_input( "\nEnter desired blade number: ") if collectEyesBlade in [range(0,9)]: break elif collectEyesBlade.lower() == 'q': return else: print "\nInvalid input. Enter value between 0 and 9, or 'q' to quit" continue

#include <Wt/WApplication>

答案 1 :(得分:0)

因此无需扩展名即可使用:

#include <Wt/WApplication>

答案 2 :(得分:0)

尝试:

g++ -std=c++14 -o hello hello.cpp -I/usr/local/include/Wt -L/usr/local/lib64/

OR

g++ -std=c++14 -o hello hello.cpp -I/usr/local/include/Wt -L/usr/local/lib/