PDA

View Full Version : new QHttp() Error



fengtian.we
3rd June 2007, 10:24
#include <QApplication>
#include <QHttp>
#include <QUrl>
#include <QFileInfo>
#include <QFile>
#include <QtDebug>

class QHttp;

int main(int argc,char *argv[])
{
QApplication qapp(argc,argv);
QHttp *http;
http=new QHttp(); // in there
return qapp.exec();
}

output:


1>------ Build started: Project: QTest, Configuration: Debug Win32 ------
1>Performing Makefile project actions
1>Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
1>Copyright (C) Microsoft Corporation. All rights reserved.
1> cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include" -I"." -I"C:/Qt/4.2.2/include/ActiveQt" -I"debug" -I"." -I"c:\Qt\4.2.2\mkspecs\win32-msvc2005" -Fodebug\ @C:\DOCUME~1\Liu\LOCALS~1\Temp\nmF1.tmp
1>main.cpp
1> link /LIBPATH:"c:\Qt\4.2.2\lib" /NOLOGO /DEBUG /DEBUG /MANIFESTFILE:"debug\QTest.intermediate.manifest" /SUBSYSTEM:WINDOWS /OUT:debug\QTest.exe @C:\DOCUME~1\Liu\LOCALS~1\Temp\nmF2.tmp
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QHttp::QHttp(class QObject *)" (__imp_??0QHttp@@QAE@PAVQObject@@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QHttp::metaObject(void)const " (?metaObject@QHttp@@UBEPBUQMetaObject@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QHttp::qt_metacast(char const *)" (?qt_metacast@QHttp@@UAEPAXPBD@Z)
1>NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 8\VC\bin\link.EXE"' : return code '0x460'
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QHttp::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QHttp@@UAEHW4Call@QMetaObject@@HPAPA X@Z)
1>Stop.
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QHttp::~QHttp(void)" (__imp_??1QHttp@@UAE@XZ) referenced in function "public: virtual void * __thiscall QHttp::`scalar deleting destructor'(unsigned int)" (??_GQHttp@@UAEPAXI@Z)
1>debug\QTest.exe : fatal error LNK1120: 5 unresolved externals
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://c:\Documents and Settings\Liu\My Documents\Visual Studio 2005\Projects\QTest\QTest\Debug\BuildLog.htm"
1>QTest - 8 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



----------------------------------------
:confused: why????

marcel
3rd June 2007, 10:28
Why do you have a forward declaration of QHttp in there? You include QHttp anyway.
What happens if you remove it?

jpn
3rd June 2007, 10:29
Applications that use Qt's networking classes need to be configured to be built against the QtNetwork module. The following declaration in a qmake project file ensures that an application is compiled and linked appropriately:

QT += network

Edit:

Why do you have a forward declaration of QHttp in there?
Ahh, good spot! :)

marcel
3rd June 2007, 10:36
Applications that use Qt's networking classes need to be configured to be built against the QtNetwork (http://doc.trolltech.com/latest/qtnetwork.html) module. The following declaration in a qmake project file ensures that an application is compiled and linked appropriately:


I am inclined to believe he is using Qt with Visual Studio because( maybe the commercial version of Qt ):


1>------ Build started: Project: QTest, Configuration: Debug Win32 ------
If I am correct, he has to add networking support from the project properties.
If he is using VS integration, then it is easy. Otherwise he has to find the preprocessor definition, which I don't remember anymore :).

Regards

fengtian.we
3rd June 2007, 10:37
OK !! QT += network is good!

forward declaration is my idea for this problem :)

this is a low prlblem

fengtian.we
3rd June 2007, 10:40
thank you sir!

hadi2f
6th October 2010, 15:05
Great, it works now finally! I've been at this for about an hour.
How come this is not done automatically by Qt Creator?


Applications that use Qt's networking classes need to be configured to be built against the QtNetwork module. The following declaration in a qmake project file ensures that an application is compiled and linked appropriately.

wysota
6th October 2010, 17:56
How come this is not done automatically by Qt Creator?
And how should Creator know you are using some class from some library or module? You can name your own class QHttp too and it's not part of the QtNetwork module.