开发者

Poco ApplicationServer linking issues with Eclipse and Mingw

开发者 https://www.devze.com 2023-03-31 20:25 出处:网络
I am attempting to get the basic ApplicationServer example from poco working.I am using: Windows 7 MinGW

I am attempting to get the basic ApplicationServer example from poco working. I am using:

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. These are popping up from the poco libraries, they are not stuff I am using in my code. My hack has been to, in my Server.cpp, go through each of the classes referenced, and use them. 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)
  • MinGW is working ok
  • 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?

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". So make your linker point to that folder which contains all the libraries for poco. Now there shoudn't be any link errors. If it says *.dll files are missing:

  • Then copy contents from folder "(pocobuild path)\bin" to project build location.Else,
  • Add "(pocobuild path)\bin" path to environment variable (PATH).
0

精彩评论

暂无评论...
验证码 换一张
取 消