发新话题
打印

qt库出问题了啊!!怎么就没人帮我??

qt库出问题了啊!!怎么就没人帮我??

好吧!!我贴我的源代码和编译过程中所报出的错误出来吧

源代码:

#include <qapplication.h>
#include <qlabel.h>
#include <qstring.h>
int main(int argc, char **argv)
{
     Qapplication app(argc,argv);
     Qlabel *label=new Qlabel(NULL);
     Qstring string("hello world");   
     label->setText(string);   
label->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);           
     label->setGeometry(0,0,180,75);   
     label->show();   
     app.setMainWidget(label);   
     return(app.exec());
}


我用来编译的命令是 g++ -o download download.cpp -L/usr/lib/qt3/include/     
/*因为我的QT库目录是在/usr/lib/qt3/include上!!*/


之后编译出来之后报出的错误是:

download.cpp:1:26: qapplication.h: No such file or directory
download.cpp:1:26: qlabel.h: No such file or directory
download.cpp:1:26: qstring.h: No such file or directory
download.cpp: In function 'int main(int,char**)':
download.cpp:7: 'Qapplication' undeclared(first use this function)
download.cpp:7: (Each undeclared identifier is reported only once for each function it appears in.)
download.cpp:7: parse error before '(' token
download.cpp:8: 'Qlabel' undeclared (first use this function)
download.cpp:8: 'label' undeclared (first use this function)
download.cpp:8: parse error before '(' token
download.cpp:9: 'Qstring' undeclared (first use this function)
download.cpp:10: 'string' undeclared (first use this function)
download.cpp:11: 'Qt' undeclared(first use this function)
download.cpp:11:parse error before '::' token
download.cpp:14: 'app' undeclared (first use this function)

大家看看我该怎么办??

之后我按照大家的意见做了一个Makefile如下:

INCL=-I$(QTDIR)/include -I$(KDEDIR)/include

CFLAGS=-pipe -O2 -fno-strength-reduce

LFLAGS=-L$(QTDIR)/lib -L$(KDEDIR)/lib -L/usr/X11R6/lib

LIBS=-lqt -lX11 -lXext

CC=g++



download: download.o
   
       $(CC) $(LFLAGS) -o download download.o $(LIBS)



download.o: download.cpp




clean:
   
   rm -f download
   
   rm -f download.o



.SUFFIXES: .cpp

.cpp.o:
     

$(CC) -c $(CFLAGS) $(INCL) -o $@ $<


但是我做了这个Makefile之后,之后执行make命令!结果冒出这样一句错误,大家看看是什么?
Makefile:8: ***missing separator.stop.

哎呀,make也不行,G++也不行,难道真要用qtdesigner或者kdeveloper
俺不想用那工具啊,只想了解低层的东西!

TOP

such as:

g++ -o download download.cpp -I/usr/lib/qt3/include -L/usr/lib/qt3/lib -lqt[/COLOR]
class faraway : public GNU { public: faraway() : _M_name("faraway"), _M_sex("Male"), _M_age(26) { } ~faraway(); private: std::string _M_name; std::string _M_sex; unsigned long _M_age; };

TOP

no!!no!! the bug still exist!!~

when I compile the program~~

the system report that "/usr/bin/ld cannot find -lqt"

what is the matter???

help me!!!! help!!

TOP

kk

好啊,谢谢,在大家的帮助下,已经好了一大半了,但是还是有问题!
我是按照下面的方法编译

g++ -o download download.cpp -L/usr/lib/qt3/lib -I/usr/lib/qt3/include -lqt

开始一路顺畅,但是后来冒出一句这样的话:
/usr/bin/ld cannot find -lqt

到底是怎么会事啊?

TOP

ok, then you have to add: -mt[/COLOR]
class faraway : public GNU { public: faraway() : _M_name("faraway"), _M_sex("Male"), _M_age(26) { } ~faraway(); private: std::string _M_name; std::string _M_sex; unsigned long _M_age; };

TOP

thanks!!

thanks~~~

and can you tell me where did you search so many information about g++???

TOP

因为新版本的qt3,的libqt.so文件已经变为libqt-mt.so,而用qmake产生的makefile里面还是引用libqt.so,所以会提示说找不到,可以用cp  libqt-mt.so   libqt.so命令解决.

TOP

发新话题