无法编译"hello world".带有Poco的Web服务器应用程序 [英] Failure to compile "hello world" web server app with Poco

查看:219
本文介绍了无法编译"hello world".带有Poco的Web服务器应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Google上搜索"poco Web服务器示例"时,它提供给我的第一个链接是这一个.现在可以肯定的是,它的星级为零,而Google从Poco那里提供了一个更官方的示例,仅次于该列表.但是,该示例非常简单,因此我尝试将其添加到现有(MFC)项目中并进行编译.当我这样做时,会出现以下错误:

When I search Google for "poco web server example", the very first link it offers me is this one. Now admittedly it has a zero star rating, and Google offers a more official example from Poco one step down the list. Nonetheless, the example is tantalisingly simple, so I tried to add it to an existing (MFC) project and compile it. When I do, I get these errors:

[...]serverapplication.h(215): error C3646: '_serviceStatus': unknown override specifier
[...]serverapplication.h(215): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
[...]serverapplication.h(216): error C3646: '_serviceStatusHandle': unknown override specifier
[...]serverapplication.h(216): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

错误在serverapplication.h的这两行中发生:

The errors occur on these two lines in serverapplication.h:

static SERVICE_STATUS        _serviceStatus; 
static SERVICE_STATUS_HANDLE _serviceStatusHandle; 

自然地,即使我所做的只是包含Poco头文件而没有其他错误,错误仍然存​​在...因此,并不是我的代码出现问题,更多的是 my环境有问题.的确,如果我用Poco自己的HTTPTimeServer示例中的较长列表替换8个Poco头文件+ 3个STL头的列表,则会得到完全相同的错误(顺便说一下,它可以作为独立项目进行编译和运行).

Naturally, the errors persist even when all I do is include the Poco header files and nothing else... so it's not as if my code has a problem, it's more that my environment has a problem. Indeed, I get precisely the same errors if I replace the list of 8 Poco header files + 3 STL headers with the longer list from Poco's own HTTPTimeServer example (which compiles and runs fine as an independent project by the way).

看起来SERVICE_STATUSSERVICE_STATUS_HANDLE完全没有定义.是否有可以做到这一点的编译器设置或预处理器定义? Poco用户应注意的陷阱是什么? Poco和MFC之间是否存在兼容性问题?

It looks like SERVICE_STATUS and SERVICE_STATUS_HANDLE are being #defined to nothing at all. Is there a compiler setting or preprocessor definition that would do this? What is the trap that Poco users should beware of falling into? Are there compatibility issues between Poco and MFC?

更新:我可以通过下载 此潜在相关文章引用的此压缩项目 ...可以正常运行...但是当我尝试指定额外的include文件夹并包含serverapplication.h时,就会发生这些错误.在Poco ServerApplication 类文档页面上没有提及任何依赖关系.

Update: I can reproduce the issue independently of my application by downloading this zipped project referenced by this potentially relevant article... which builds fine... but the moment I try to specify the extra include folder and include serverapplication.h, these errors occur. There is no mention of any dependencies on the Poco ServerApplication class documentation page.

推荐答案

要将POCO的ServerApplication.h头文件包含在MFC项目中,请在#include "ServerApplication.h"之前尝试#include <winsvc.h>.请注意,您不得在MFC项目中包含Windows.h,而该项目通常会包含winsvc.h.

To include POCO's ServerApplication.h header file in an MFC project, try #include <winsvc.h> prior to #include "ServerApplication.h". Note that you must not include Windows.h in an MFC project, which would normally include winsvc.h.

这篇关于无法编译"hello world".带有Poco的Web服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆