用gcc make
代码:/* helloworld.cpp */
#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());
}
makefile:
INCL= -I$(QTDIR)/include -I$(KDEDIR)/include
CFLAGS= -O2 -fno-strength-reduce
LFLAGS= -L$(QTDIR)/lib -L$(KDEDIR)/lib -L/usr/X11R6/lib
LIBS= -lqt -lX11 -lXext
CC=g++
helloworld: helloworld.o
$(CC) $(LFLAGS) -o helloworld helloworld.o $(LIBS)
helloworld.o: helloworld.cpp
clean:
rm -f helloworld
rm -f helloworld.o
.SUFFIXES: .cpp
.cpp.o:
$(CC) -c $(CFLAGS) $(INCL) -o $@ $<
在ksonle用 make就好了