I'm trying to use the poco library in Qt Creator with one of the samples that come with poco, I got this to work in Visual Studio 2012, but I keep getting build errors in Qt Creator. I have both .dll and .lib in my lib path.
here is my .pro file
TEMPLATE = app CONFIG += console CONFIG -= qt SOURCES += main.cpp INCLUDEPATH += C:\Users\justin\Downloads\poco-1.4.6\Net\include INCLUDEPATH += C:\Users\justin\Downloads\poco-1.4.6\Foundation\include win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lPocoFoundation else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lPocoFoundationd INCLUDEPATH += $$PWD/ DEPENDPATH += $$PWD/ win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/PocoFoundation.lib else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/PocoFoundationd.lib win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lPocoNet else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lPocoNetd INCLUDEPATH += $$PWD/ DEPENDPATH += $$PWD/ win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/PocoNet.lib else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/PocoNetd.lib
and here is the .cpp file
#include "Poco/URIStreamOpener.h" #include "Poco/StreamCopier.h" #include "Poco/Path.h" #include "Poco/URI.h" #include "Poco/Exception.h" #include "Poco/Net/HTTPStreamFactory.h" #include "Poco/Net/FTPStreamFactory.h" #include <memory> #include <iostream> using Poco::URIStreamOpener; using Poco::StreamCopier; using Poco::Path; using Poco::URI; using Poco::Exception; using Poco::Net::HTTPStreamFactory; using Poco::Net::FTPStreamFactory; int main(int argc, char** argv) { HTTPStreamFactory::registerFactory(); FTPStreamFactory::registerFactory(); try { URI uri("http://example.com"); std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri)); StreamCopier::copyStream(*pStr.get(), std::cout); } catch (Exception& exc) { std::cerr << exc.displayText() << std::endl; return 1; } return 0; }
and these are build errors:
undefined reference to `Poco::Net::HTTPStreamFactory::registerFactory()' undefined reference to `Poco::Net::FTPStreamFactory::registerFactory()' undefined reference to `Poco::URI::URI(char const*)' undefined reference to `Poco::URIStreamOpener::defaultOpener()' undefined reference to `Poco::URIStreamOpener::open(Poco::URI const&) const' undefined reference to `Poco::StreamCopier::copyStream(std::istream&, std::ostream&, unsigned int)' undefined reference to `Poco::URI::~URI()' undefined reference to `Poco::URI::~URI()'
source share