Poco ApplicationServer与Eclipse和Mingw的链接问题

Poco ApplicationServer linking issues with Eclipse and Mingw

本文关键字:链接 问题 Mingw ApplicationServer Eclipse Poco      更新时间:2023-10-16

我试图从poco工作中获得基本的ApplicationServer示例。我正在使用:

Windows 7MinGW少Eclipsec++

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

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

我认为我可以总结的事情:

  • poco库已经建立正确(他们工作一旦我有这个hack到位)
  • MinGW工作正常
  • eclipse设置可能没有正确链接。

所以我的问题是:有没有人知道是什么设置错了,可能导致这种行为?我如何用一个"干净"的解决方案来解决这个问题,而不是我那令人无法接受的凌乱的hack?

我的hack main解决问题:

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

当你构建poco时,你会得到一个名为"lib"的文件夹。让你的链接器指向那个包含poco所有库的文件夹。现在应该没有任何链接错误了。如果显示*.dll文件丢失:

  • 然后从文件夹"(pocobuild路径)bin"复制内容到项目构建位置。,
  • 为环境变量(path)添加"(pocobuild path)bin"路径。