【发布时间】:2011-08-31 15:03:09
【问题描述】:
我正在尝试从 poco 工作中获取基本的 ApplicationServer 示例。我正在使用:
Windows 7 明威 波科 蚀 c++
所以经过一堆黑客和设置后,我终于让它工作了。但我不知道我的 hack 做了什么,我想要一个适当的解决方案,而不是我的 hack。
我遇到的问题是,当我构建时,它给了我一堆“未解决的 XX 引用”。这些是从 poco 库中弹出的,它们不是我在代码中使用的东西。 我的技巧是,在我的 Server.cpp 中,遍历每个引用的类,并使用它们。仅仅声明它们是不够的,我必须实际使用该对象。一旦我使用了它所抱怨的所有内容,它就会编译并按预期运行。对于知道发生了什么的人来说,这似乎是一种简单的配置解决方案。
我想我可以得出结论:
- poco 库已正确构建(一旦我有了这个 hack,它们就可以工作)
- MinGW 工作正常
- eclipse 设置可能连接不正确。
所以我的问题是:有谁知道是什么设置错误,可能导致这种行为?我该如何为此提出一个“干净”的解决方案,而不是我无法接受的混乱黑客?
解决问题的我的黑客主:
int main(int argc, char** argv)
{
std::cout << "test1" << std::endl;
std::cout.flush();
AgentServer app;
app.run(argc, argv);
LoggingFactory::defaultFactory();
AutoPtr<ConsoleChannel> pCCChannel(new ConsoleChannel);
AutoPtr<FileChannel> pChannel(new FileChannel);
pChannel->setProperty("path", "sample.log");
pChannel->setProperty("rotation", "2 K");
pChannel->setProperty("archive", "timestamp");
Logger::root().setChannel(pChannel);
Logger& logger = Logger::get("TestLogger"); // inherits root channel
poco_warning(logger, "This is a warning");
try
{
Path myPath = new Path();
poco_warning(logger, myPath.current());
int i = NumberParser::parse("5");
FileOutputStream myFileOutputStream("test.file");
myFileOutputStream << "test";
OutputLineEndingConverter conv(myFileOutputStream," ");
std::stringstream xmlstream("test");
UTF8Encoding myUTF8Encoding;
XMLWriter writer(xmlstream,0,"UTF-8", &myUTF8Encoding);
std::ostringstream ostr1("test2");
OutputStreamConverter converter1(ostr1,myUTF8Encoding,myUTF8Encoding);
URI uri;
uri.getHost();
URIStreamOpener opener;
opener.open(uri);
} catch(...)
{
poco_warning(logger, "Swallowing exception");
}
//poco_warning(logger,);
//AgentServer app;
//return app.run(argc, argv);
}
【问题讨论】:
标签: c++ eclipse mingw poco-libraries