LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problems in qt (https://www.linuxquestions.org/questions/linux-newbie-8/problems-in-qt-379029/)

Raphexion 11-01-2005 01:36 PM

Problems in qt
 
Hey all!

I am trying to get qt3 to work on my debian system.

I am trying to 'compile' hello.cpp (from C++ GUI Programming with Qt 3):
#include <qapplication.h>
#include <qlabel.h>

int main (argc, char *argv[]) {

QApplication app (argc, argv);
QLabel *label = new QLabel ("Hello Qt!", 0);
app.setMainWidget (label);
label->show();
return app.exec();
}

But in the command promp i get:
$ qmake -project
$ make
g++ -o hello -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../crt1.o(.text+0x18): In function `_start':
../sysdeps/i386/elf/start.S:98: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1
$

I have absolutely no clue what this mean ???

My Makefile looks like this:
#############################################################################
# Makefile for building: hello
# Generated by qmake (1.07a) (Qt 3.3.4) on: Tue Nov 1 19:45:55 2005
# Project: hello.cpp
# Template: app
# Command: $(QMAKE) -o Makefile hello.cpp
#############################################################################

####### Compiler, tools and options

CC = gcc
CXX = g++
LEX = flex
YACC = yacc
CFLAGS = -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT
CXXFLAGS = -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT
LEXFLAGS =
YACCFLAGS= -d
INCPATH = -I/usr/share/qt3/mkspecs/default -I. -I/usr/include/qt3
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
AR = ar cqs
RANLIB =
MOC = /usr/share/qt3/bin/moc
UIC = /usr/share/qt3/bin/uic
QMAKE = qmake
TAR = tar -cf
GZIP = gzip -9f
COPY = cp -f
COPY_FILE= $(COPY)
COPY_DIR = $(COPY) -r
INSTALL_FILE= $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
DEL_FILE = rm -f
SYMLINK = ln -sf
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p

####### Output directory

OBJECTS_DIR = ./

####### Files

HEADERS =
SOURCES =
OBJECTS =
FORMS =
UICDECLS =
UICIMPLS =
SRCMOC =
OBJMOC =
DIST = hello.cpp
QMAKE_TARGET = hello
DESTDIR =
TARGET = hello

first: all
####### Implicit rules

.SUFFIXES: .c .o .cpp .cc .cxx .C

.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

####### Build rules

all: Makefile $(TARGET)

$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)

mocables: $(SRCMOC)
uicables: $(UICDECLS) $(UICIMPLS)

$(MOC):
( cd $(QTDIR)/src/moc && $(MAKE) )

Makefile: hello.cpp /usr/share/qt3/mkspecs/default/qmake.conf /usr/share/qt3/lib/libqt-mt.prl
$(QMAKE) -o Makefile hello.cpp
qmake:
@$(QMAKE) -o Makefile hello.cpp

dist:
@mkdir -p .tmp/hello && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/hello/ && ( cd `dirname .tmp/hello` && $(TAR) hello.tar hello && $(GZIP) hello.tar ) && $(MOVE) `dirname .tmp/hello`/hello.tar.gz . && $(DEL_FILE) -r .tmp/hello

mocclean:

uiclean:

yaccclean:
lexclean:
clean:
-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
-$(DEL_FILE) $(TARGET) $(TARGET)


FORCE:

####### Compile

####### Install

install:

uninstall:

Tinkster 11-01-2005 02:15 PM

Hi, and welcome to LQ!

How did you install Qt, which steps did you take to do so?


Cheers,
Tink

P.S.: Would you mind if I moved this to the programming forum?

Mara 11-01-2005 03:39 PM

You don't have your .cpp file in SOURCES in Makefile. That's why it doesn't add it what results in the lack of main().

Raphexion 11-03-2005 07:28 AM

Thanks!!!

Raphexion 11-03-2005 11:09 AM

damn,
 
didn't work with adding hello.cpp to SOURCES...

First reply.
I use synaptic to add basicly anything with the name qt3...

Thanks for all quike help before =)
/ Raphexion

foo_bar_foo 11-03-2005 11:33 PM

ok first step you got hello.cpp
i make a few small changes to line 4
Code:


int main (int argc, char **argv) {

second step make hello.pro
Code:

TEMPLATE        = app
TARGET                = hello

CONFIG                += qt warn_on release

HEADERS                =
SOURCES                = hello.cpp

third step type
qmake -o Makefile hello.pro
then
make
then
./hello
to run it and see the perty application

Raphexion 11-04-2005 01:29 AM

Okay, now it works! Thanks for your help =) !!!

I understand the one ot the problems (int argc instead of just argc) but I don't really understand the *magic
with qmake, .pro files and Makefiles. Do you recommend any books or online resources to read up on to understand theses things.

Once more, thanks for the help. LQ RULES!

// RAPHEXION


All times are GMT -5. The time now is 09:15 PM.