C++ C++;-Qt-Creator中的Poco库

C++ C++;-Qt-Creator中的Poco库,c++,qt,poco-libraries,C++,Qt,Poco Libraries,我试图将Qt Creator中的poco库与poco附带的一个示例一起使用,我已经在Visual Studio 2012中实现了这一点,但我在Qt Creator中不断遇到构建错误。 我的库路径中同时有.dll和.lib 这是我的.pro文件 TEMPLATE = app CONFIG += console CONFIG -= qt SOURCES += main.cpp INCLUDEPATH += C:\Users\justin\Downloads\poco-1.4.6\Net\inclu

我试图将Qt Creator中的poco库与poco附带的一个示例一起使用,我已经在Visual Studio 2012中实现了这一点,但我在Qt Creator中不断遇到构建错误。 我的库路径中同时有.dll和.lib

这是我的.pro文件

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
这是.cpp文件

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

必须使用同一个编译器编译以下三项:

  • Poco图书馆

  • Qt库

  • 你的申请


  • 我的直觉是,您使用MSVC2012作为#3,正确下载了#2作为MSVC2012,但您没有使用MSVC2012编译#1。

    您是在Qtcreator中使用MSVC2012,还是在mingw中使用?不能使用MSVC编译的C++库和MIWW,反之亦然。另外,qmake逻辑看起来有点奇怪:我建议使用win32{CONFIG(…){…}else{…}。不需要预先设置TARGETDEPS。
    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()'