简体   繁体   English

C ++ - Qt Creator中的Poco库

[英]C++ - Poco library in Qt Creator

I am trying to use the poco library in Qt Creator with one of the samples that came with poco, I have gotten this to work in Visual Studio 2012 but I keep getting build errors in Qt Creator. 我正在尝试使用Qt Creator中的poco库和poco附带的一个示例,我已经在Visual Studio 2012中使用它,但我在Qt Creator中不断出现构建错误。 I have both .dll and .lib in my lib path. 我的lib路径中有.dll和.lib。

here is my .pro file 这是我的.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

and here is the .cpp file 这是.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;
}

and these are the 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()'

The same compiler must be used to compile all three of the below: 必须使用相同的编译器来编译以下所有三个:

  1. Poco library Poco图书馆

  2. Qt library Qt库

  3. Your application 你的申请

My hunch is that you use MSVC2012 for #3, you correctly downloaded #2 for MSVC2012, but you did not compile #1 with MSVC2012. 我的预感是你使用MSVC2012作为#3,你正确地为MSVC2012下载了#2,但你没有使用MSVC2012编译#1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM