You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, August 6th 2005, 12:39am

Qt 4.0: Qhttp problem???

I was trying to learn how to use QHttp class on Qt 4.0. I can't include QHttp header file properly. I compiled Qt4 by myself. Everything is working fine, except the QHttp class. I attached the Makefile, and list the error message and my main.cpp. I really want to get the problem solved.

Thanks in advance.

Fei

The make output is:

Source code

1
2
3
4
5
6
7
8
9
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SHARED -I/scratch/fei/qt-x11-4.0.0/mkspecs/default -I. -I../../../include/QtGui -I../../../include/QtCore -I../../../include -I. -I. -I. -o main.o main.cpp
g++ -Wl,-rpath,/scratch/fei/qt-x11-4.0.0/lib -o httpdownload main.o   -L/scratch/fei/qt-x11-4.0.0/lib -L/scratch/fei/qt-x11-opensource-desktop-4.0.0/lib -lQtGui_debug -L/usr/X11R6/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lm -lQtCore_debug -lz -ldl -lpthread
main.o(.text+0x139): In function `main':
/scratch/fei/qt-x11-4.0.0/examples/kingsoft/httpdownload/main.cpp:13: undefined reference to `QHttp::QHttp(QObject*)'
main.o(.text+0x1bb):/scratch/fei/qt-x11-4.0.0/examples/kingsoft/httpdownload/main.cpp:23: undefined reference to `QHttp::closeConnection()'
main.o(.text+0x1f0):/scratch/fei/qt-x11-4.0.0/examples/kingsoft/httpdownload/main.cpp:27: undefined reference to `QHttp::~QHttp()'
main.o(.text+0x236):/scratch/fei/qt-x11-4.0.0/examples/kingsoft/httpdownload/main.cpp:27: undefined reference to `QHttp::~QHttp()'
collect2: ld returned 1 exit status
make: *** [httpdownload] Error 1




Here is my main.cpp

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <QApplication>
#include <QFile>
//#include <QtNetwork/QHttp>
#include <Qt/QHttp>
#include <QPushButton>
#include <QIODevice>

int main(int argc, char *argv[]) {
  QApplication app(argc, argv);
  QHttp http;
  
  QFile file("temp.html");
  if (!file.open(QIODevice::WriteOnly)) {
       return;
  }

  //http.setHost("www.trolltech.com");
  // http.get("index.html", &file);
  http.closeConnection();

  file.close();
  return app.exec();
}

This post has been edited 1 times, last edit by "fei" (Aug 6th 2005, 9:13am)


  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

2

Saturday, August 6th 2005, 9:52am

You have to activate the network library in the .pro file (CONFIG += network).

3

Sunday, August 7th 2005, 6:08am

I found a way of solving that problem: add '-lQtNetwork' to the auto-genereated Makefile. I think modify the .pro is a more proper way.

Is there a way to let the qmake to automatically include the network lib? I don't want to change the .pro file every time I have to re-qmake. Is this a bug or it's the way the Qt is designed for?

Thanks!

Fei

4

Sunday, August 7th 2005, 8:24am

I would tend to think it's a bug since I have encountered the same problem when using QTcpSocket. Editing the .pro file does no good, I also have to manually edit the Makefile. This occurs with the opensource version of Qt under Linux; I don't know what version you are using?

5

Sunday, August 7th 2005, 8:41am

Are you saying that it only happens with opensource version, but not commercial version? (If it's really the case. Even though Qt is easy and free to use, it really sucks.)

I'm using Qt 4.0 opensource version on Fedora. I also tested my QHttp program on windows using Qt4 opensource version, it has the same problem.

This post has been edited 1 times, last edit by "fei" (Aug 7th 2005, 8:47am)


  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

6

Sunday, August 7th 2005, 9:39am

Sorry, should ber "QT+=network". See qmake reference for more info.