我正在嘗試從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);
}