LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2005, 01:36 PM   #1
Raphexion
LQ Newbie
 
Registered: Nov 2005
Location: Sweden
Distribution: Suse 10.0
Posts: 8

Rep: Reputation: 0
Question 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:
 
Old 11-01-2005, 02:15 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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?
 
Old 11-01-2005, 03:39 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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().
 
Old 11-03-2005, 07:28 AM   #4
Raphexion
LQ Newbie
 
Registered: Nov 2005
Location: Sweden
Distribution: Suse 10.0
Posts: 8

Original Poster
Rep: Reputation: 0
Smile

Thanks!!!
 
Old 11-03-2005, 11:09 AM   #5
Raphexion
LQ Newbie
 
Registered: Nov 2005
Location: Sweden
Distribution: Suse 10.0
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
Old 11-03-2005, 11:33 PM   #6
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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
 
Old 11-04-2005, 01:29 AM   #7
Raphexion
LQ Newbie
 
Registered: Nov 2005
Location: Sweden
Distribution: Suse 10.0
Posts: 8

Original Poster
Rep: Reputation: 0
Thumbs up

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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ethernet Adsl Modem Driver Problems And Install Problems... akhilnair Linux - Hardware 12 11-28-2004 08:19 AM
cisco 350 wireless problems and suse x-server problems incognito9 Linux - Wireless Networking 5 10-14-2004 07:53 AM
Problems with OSS while trying to avoid problems in ALSA (scratchy sound) GT_Onizuka Linux - General 1 02-05-2004 11:55 PM
Problems, problems, problems. Lets start with the soundcard Kre8ive Linux - Newbie 5 08-07-2003 01:20 AM
Problems, problems, problems. Lets start with the ES 1868 AudioDrive Kre8ive Linux - Newbie 1 08-06-2003 07:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration