简体   繁体   English

Poco ApplicationServer与Eclipse和Mingw的链接问题

[英]Poco ApplicationServer linking issues with Eclipse and Mingw

I am attempting to get the basic ApplicationServer example from poco working. 我正在尝试从poco工作中获取基本的ApplicationServer示例。 I am using: 我在用:

Windows 7 MinGW Poco Eclipse c++ Windows 7 MinGW Poco Eclipse c ++

So after a bunch of hacking and settings, I have eventually got it working. 因此,经过一堆黑客和设置后,我终于使它工作了。 But I don't know what my hacks have done, and I want a proper solution, not my hack. 但是我不知道我的黑客做了什么,我想要一个合适的解决方案,而不是我的黑客。

The problem I have is that it gives me a bunch of 'unresolved reference to XX' when I build. 我的问题是在构建时它给了我一堆“未解决的对XX的引用”。 These are popping up from the poco libraries, they are not stuff I am using in my code. 这些是从poco库中弹出的,它们不是我在代码中使用的东西。 My hack has been to, in my Server.cpp, go through each of the classes referenced, and use them. 我的技巧是在Server.cpp中遍历引用的每个类,然后使用它们。 Simply declaring them is not enough, I have to actually use the object. 仅仅声明它们是不够的,我必须实际使用该对象。 Once I have used everything that it was complaining about, it compiles, and runs as expected. 一旦我使用了它抱怨的所有内容,它就会编译并按预期运行。 This seems like behaviour that will indicate a simple configuration solution to someone who knows what is going on. 这似乎是一种行为,它将为知道所发生情况的人员提供简单的配置解决方案。

Things I think I can conclude: 我想可以得出的结论是:

  • The poco libraries have been built right (they work once I have this hack in place) poco库已正确构建(一旦我安装了此hack,它们便可以工作)
  • MinGW is working ok MinGW工作正常
  • The eclipse setup is maybe not linking things right. 蚀设置可能没有正确链接。

So my question is: Does anyone know what it is that is set up wrong, that might cause this behaviour? 所以我的问题是:有人知道设置错误是什么,可能会导致这种行为吗? How do I put in a 'clean' solution to this, rather than my unacceptably messy hack? 我该如何为此提供“干净”的解决方案,而不是我无法接受的凌乱的hack?

My Hacked main that gets around the problem: 我被黑的主线解决了这个问题:

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

When you build poco you'll get a folder named "lib". 构建poco时,将获得一个名为“ lib”的文件夹。 So make your linker point to that folder which contains all the libraries for poco. 因此,使链接器指向包含poco所有库的文件夹。 Now there shoudn't be any link errors. 现在应该没有任何链接错误。 If it says *.dll files are missing: 如果显示* .dll文件丢失:

  • Then copy contents from folder "(pocobuild path)\\bin" to project build location.Else, 然后将内容从文件夹“(pocobuild path)\\ bin”复制到项目构建位置。否则,
  • Add "(pocobuild path)\\bin" path to environment variable (PATH). 将“(pocobuild路径)\\ bin”路径添加到环境变量(PATH)。

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

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