繁体   English   中英

WT a.exe文件无法运行

[英]Wt a.exe file won't run

我正在尝试开始在WT中进行开发,但没有成功。 我正在使用Windows 8,下载了Wt 3.3.1,并下载了具有GCC编译器和GDB调试器的codeblocks-12.11mingw-setup_user.exe。 但是我没有使用代码块,因为编译器不喜欢WtConfig.h中的cmake preproccessor指令。 因此,我尝试手动进行编译(我是使用这种技术的新手,因此我必须进行查找)。

我的项目如下:

└───HelloWorldWt
    └───source
        ├───bin
        │   ├───Debug
        │   │   └───CMakeFiles
        │   │       └───CMakeFiles
        │   └───Release
        ├───build
        └───source
        |   └───CMakeFiles
        |       └───wt_project.wt.dir
        |       |___CMakeLists.txt
        |       |
        |       |___main.cpp
        |____CMakeLists.txt

main.cpp具有(这是来自http://www.webtoolkit.eu/wt/examples/的HelloWorld示例):

/ * *版权所有(C)2008 Emweb bvba,比利时Heverlee。 * *有关使用条款,请参阅LICENSE文件。 * /

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

// c++0x only, for std::bind
// #include <functional>

using namespace Wt;

/*
 * A simple hello world application class which demonstrates how to react
 * to events, read input, and give feed-back.
 */
class HelloApplication : public WApplication
{
public:
  HelloApplication(const WEnvironment& env);

private:
  WLineEdit *nameEdit_;
  WText *greeting_;

  void greet();
};

/*
 * The env argument contains information about the new session, and
 * the initial request. It must be passed to the WApplication
 * constructor so it is typically also an argument for your custom
 * application constructor.
*/
HelloApplication::HelloApplication(const WEnvironment& env)
  : WApplication(env)
{
  setTitle("Hello world");                               // application title

  root()->addWidget(new WText("Your name, please ? "));  // show some text
  nameEdit_ = new WLineEdit(root());                     // allow text input
  nameEdit_->setFocus();                                 // give focus

  WPushButton *button
    = new WPushButton("Greet me.", root());              // create a button
  button->setMargin(5, Left);                            // add 5 pixels margin

  root()->addWidget(new WBreak());                       // insert a line break

  greeting_ = new WText(root());                         // empty text

  /*
   * Connect signals with slots
   *
   * - simple Wt-way
   */
  button->clicked().connect(this, &HelloApplication::greet);

  /*
   * - using an arbitrary function object (binding values with boost::bind())
   */
  nameEdit_->enterPressed().connect
    (boost::bind(&HelloApplication::greet, this));

  /*
   * - using a c++0x lambda:
   */
  // b->clicked().connect(std::bind([=]() {
  //       greeting_->setText("Hello there, " + nameEdit_->text());
  // }));
}

void HelloApplication::greet()
{
  /*
   * Update the text, using text input into the nameEdit_ field.
   */
  greeting_->setText("Hello there, " + nameEdit_->text());
}

WApplication *createApplication(const WEnvironment& env)
{
  /*
   * You could read information from the environment to decide whether
   * the user has permission to start a new application
   */
  return new HelloApplication(env);
}

int main(int argc, char **argv)
{
  /*
   * Your main method may set up some shared resources, but should then
   * start the server application (FastCGI or httpd) that starts listening
   * for requests, and handles all of the application life cycles.
   *
   * The last argument to WRun specifies the function that will instantiate
   * new application objects. That function is executed when a new user surfs
   * to the Wt application, and after the library has negotiated browser
   * support. The function should return a newly instantiated application
   * object.
   */
  int retval = WRun(argc, argv, &createApplication);
  char* ch = new ch();
  cin() >> ch;
  return retval;
}

HelloWorldWt / CMakeLists.txt具有:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(WT_HELLO_WORLD)

SET (WT_CONNECTOR "wtfcgi" CACHE STRING "Connector used (wthttp or wtfcgi)")

ADD_SUBDIRECTORY(source)

HelloWorldWt / source / CMakeLists.txt具有

SET(WT_PROJECT_SOURCE
main.cpp
)

SET(WT_PROJECT_TARGET wt_project.wt)

ADD_EXECUTABLE(${WT_PROJECT_TARGET} ${WT_PROJECT_SOURCE})

TARGET_LINK_LIBRARIES(${WT_PROJECT_TARGET} ${WT_CONNECTOR} wt)

INCLUDE_DIRECTORIES("C:/Users/Me/My Code Libraries/wt-3.3.1/src")

然后我跑了

cmake .. -G "MinGW Makefiles" from the MyCode directory

这创建了一些文件,其中包括cmake_install.cmake和其他文件。

然后我运行:cmake .. -G“ HelloWorldWt / source”“ MinGW Makefiles”然后我运行:cmake -P cmake_install.cmake

然后,我得到了:我的Code \\ HelloWorldWt \\ source \\ build \\ CMakeFiles \\ 2.8.12 \\ CompilerIdCXX \\ a.exe文件,然后单击该程序来运行它,然后打开并关闭了控制台窗口。

我在这里想念的是什么?,我正在尝试运行Wt应用程序,但似乎还不能这样做

(也许我应该注意,当我使用命令时:

cmake -P cmake_install.cmake

cmd控制台,回复

-- Install configuration: ""

然后返回到提示。 -如果有帮助)。

 My Code\HelloWorldWt\source\build\CMakeFiles\2.8.12\CompilerIdCXX\a.exe

不是您要运行的文件 这是cmake在配置期间创建的内部CMake测试,以验证所选的编译器甚至可以编译并检测目标体系结构。

您的可执行文件将被称为

My Code\HelloWorldWt\source\build\wt_project.wt.exe

当您实际编译它时

要编译它,您可以根据选定的生成器调用make或其他适当的build命令,或者可以要求cmake使用以下命令为您调用它:

cmake --build .

您粘贴的代码包含语法错误-

cin() >> ch;

应该

std::cin >> ch;

(并且ch应该是char ,而不是char * )-确认您尚未尝试对其进行编译。

我应该简要介绍一下WT文档,这表明生成的可执行文件在执行任何有趣的操作之前还需要很多选择。

我们使用g ++是因为它具有c ++接口(与gcc相对),并使用scons作为构建模型。 这很好用,并且部署起来非常简单。 我建议尝试下一个Ubuntu 14.04版本,因为它的软件包中将包含稳定的Wt版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM