0

我正在尝试从 poco 工作中获取基本的 ApplicationServer 示例。我在用:

Windows 7 MinGW Poco Eclipse c++

所以经过一堆黑客和设置后,我最终让它工作了。但我不知道我的黑客做了什么,我想要一个适当的解决方案,而不是我的黑客。

我遇到的问题是,当我构建时,它给了我一堆“未解决的对 XX 的引用”。这些是从 poco 库中弹出的,它们不是我在代码中使用的东西。我的技巧是,在我的 Server.cpp 中,遍历每个引用的类,并使用它们。仅仅声明它们是不够的,我必须实际使用该对象。一旦我使用了它所抱怨的所有内容,它就会编译并按预期运行。这似乎是向知道发生了什么的人指示简单配置解决方案的行为。

我想我可以得出结论:

  • poco 库已经正确构建(一旦我有了这个 hack,它们就可以工作)
  • MinGW 工作正常
  • 日食设置可能没有正确链接。

所以我的问题是:有谁知道是什么设置错误,可能导致这种行为?我如何为此提出一个“干净”的解决方案,而不是我无法接受的凌乱黑客?

我的黑客主要解决了这个问题:

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);
}
4

1 回答 1

0

当你构建 poco 时,你会得到一个名为“lib”的文件夹。所以让你的链接器指向包含所有 poco 库的文件夹。现在不应该有任何链接错误。如果它说 *.dll 文件丢失:

  • 然后将文件夹“(pocobuild path)\bin”中的内容复制到项目构建位置。否则,
  • 将“(pocobuild path)\ bin”路径添加到环境变量(PATH)。
于 2011-10-04T10:20:05.680 回答