2011-08-31 36 views
0

我正在尝试从poco工作中获取基本的ApplicationServer示例。我使用:Poco ApplicationServer与Eclipse和Mingw链接问题

Windows 7的 MinGW的 波科 的Eclipse C++

等一帮黑客和设置后,我终于得到它的工作。但我不知道我的黑客做了什么,我想要一个适当的解决方案,而不是我的黑客。

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

事情,我想我可以得出结论:

  • 的POCO库已经正确建立(他们的工作,一旦我有这样的黑客到位)
  • 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); 
} 

回答

0

当你建立的POCO你会得到一个文件夹命名为“LIB”。所以让你的链接器指向那个包含所有poco库的文件夹。现在应该没有任何链接错误。 如果说* .dll文件丢失:

  • 然后从内容文件夹中复制 “(pocobuild路径)\ BIN” 项目建设location.Else,
  • 添加 “(pocobuild路径)\ BIN” 路径到环境变量(PATH)。