PDA

View Full Version : compilation error



jjbabu
7th April 2009, 11:50
after installing qt,i just for checking i compiled


#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}


but compiler showing below error:


hello.cpp:9:2: warning: no newline at end of file
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\hello.exe tmp/obj/debug_shared/
hello.o -L"c:\Qt\4.4.3\lib" -L"c:\Program Files\SQLXML 4.0\bin\" -L"c:\Qt\4.4.3
\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
tmp/obj/debug_shared/hello.o(.text+0x158): In function `Z5qMainiPPc':
C:/Qt/4.4.3/hello/hello.cpp:5: undefined reference to `_imp___ZN12QApplicationC1
ERiPPci'
tmp/obj/debug_shared/hello.o(.text+0x1ec):C:/Qt/4.4.3/hello/hello.cpp:6: undefin
ed reference to `_imp___ZN6QLabelC1ERK7QStringP7QWidget6QFlagsIN2Q t10WindowTypeE
E'
tmp/obj/debug_shared/hello.o(.text+0x2b2):C:/Qt/4.4.3/hello/hello.cpp:8: undefin
ed reference to `_imp___ZN12QApplication4execEv'
tmp/obj/debug_shared/hello.o(.text+0x2cf):C:/Qt/4.4.3/hello/hello.cpp:8: undefin
ed reference to `QApplication::~QApplication()'
tmp/obj/debug_shared/hello.o(.text+0x2fe):C:/Qt/4.4.3/hello/hello.cpp:8: undefin
ed reference to `QApplication::~QApplication()'
tmp/obj/debug_shared/hello.o(.text$_ZN7QStringD1Ev[QString::~QString()]+0x20): I
n function `ZSt3minIjERKT_S2_S2_':
C:/Qt/4.4.3/hello/../include/QtCore/../../src/corelib/tools/qstring.h: undefined
reference to `_imp___ZN7QString4freeEPNS_4DataE'
tmp/obj/debug_shared/hello.o(.text$_ZN7QStringC1EPKc[QString::QString(char const
*)]+0x19):C:/Qt/4.4.3/hello/../include/QtCore/../../src/corelib/tools/qstring.h:
undefined reference to `_imp___ZN7QString16fromAscii_helperEPKci'
/mingw/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `Win
Main@16'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\hello.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/4.4.3/hello'
mingw32-make: *** [debug-all] Error 2


what does it mean?can anyone help me....
thanks in advance.

talk2amulya
7th April 2009, 12:01
what kind of application did you create? Qt Console or Qt Gui?

jjbabu
7th April 2009, 12:23
QtGui only.
i just want to check whether "hello qt" label will be displayed or not.

lyuts
7th April 2009, 12:41
What is in your .pro file?

jjbabu
7th April 2009, 12:55
this is my .pro file:


TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
SOURCES += hello.cpp

lyuts
7th April 2009, 12:56
Try adding QT += gui to you .pro file.

talk2amulya
7th April 2009, 12:58
u havent included QtGui..QApplication and QLabel are both part of it

jjbabu
7th April 2009, 13:09
I tried by adding "QT += gui" to my .pro file and also i included "#include <QtGui>" in my .cpp file,but the result is same.

i have visual studio 2005 in my system,but i have not integrated my qt with visual studio.
is VS2005 cause for this errors?

previously i installed qt with minGW on my windows system with out having VS2005.at that time examples of qt are compiled fine,but know i am facing this problem.

what is the reason behind this anyone can explain?
thanks...

spirit
7th April 2009, 13:16
Try adding QT += gui to you .pro file.

this flag included by default, from docs


By default, QT contains both core and gui, ensuring that standard GUI applications can be built without further configuration.

spirit
7th April 2009, 13:18
I tried by adding "QT += gui" to my .pro file and also i included "#include <QtGui>" in my .cpp file,but the result is same.

i have visual studio 2005 in my system,but i have not integrated my qt with visual studio.
is VS2005 cause for this errors?

previously i installed qt with minGW on my windows system with out having VS2005.at that time examples of qt are compiled fine,but know i am facing this problem.

what is the reason behind this anyone can explain?
thanks...

did you build Qt for VS2005?

lyuts
7th April 2009, 13:23
this flag included by default, from docs

Yeah, that's right until a user modifies qmake.conf. Someone might prefer to change the default settings.

jjbabu
7th April 2009, 13:23
of course by default that will be added to our project,but what are the reasons behind those errors.i tried so many ways,but i couldn't rectify those errors.not even examples in the qt are running.

spirit
7th April 2009, 13:25
ask you again: did you build Qt for VS2005? :)
do you use only minGW or VS2005 too?

jjbabu
7th April 2009, 13:25
i have not build qt with VS2005.i am directly using qt.

spirit
7th April 2009, 13:28
so, why did you ask about VS? I thought that you have Qt built for MinGW and you try to use this Qt version with VS. :)
did you try to make mingw32-make clean & qmake & mingw32-make?

jjbabu
7th April 2009, 13:43
Spirit let me explain clearly what is my problem:

STEP1:there is no qt on my machine,it is having VS2005 and .NET framework.

STEP2:Now i want to develope QT applications,For that reason i downloaded QT version "qt-win-opensource-4.4.3-mingw" and installed along with MINGW in my "C" directory.

STEP3:i created folder in "C:\Qt\4.4.3" with the name hello and i placed "hello.cpp" file

STEP4:using "QT4.4.3 command prompt" i compiled my application,for compilation i used
qmake -project ; qmake ;make.

at this point of time i got errors of unreferensed which are montion in my 1st post.

where i did wrong? please help me...

spirit
7th April 2009, 13:49
looks like you did right steps.
can you show us what returns this command echo %QTDIR% in "QT4.4.3 command prompt".

jjbabu
7th April 2009, 13:53
it is showing like below:

C:\Qt\4.4.3

jjbabu
7th April 2009, 14:00
are u interested to see any of my system variables and user variables?

spirit
7th April 2009, 14:14
I don't know what to say you, looks like you did everything right.
I don't know what to suggest you except as remove this Qt installation at all, reinstall it and try to compile an example again.

jjbabu
7th April 2009, 14:19
i did 3times(QT uninstall and installation) as u mentioned in your last post,but no use..i am using qt from last 3 yrs,but i never faced this type of problem.

talk2amulya
7th April 2009, 21:54
i think after VS2005 was installed by you, some internal variables changed, i m not sure though..could you please post the make file that qmake generates..

marcel
7th April 2009, 23:32
I don't know what to say you, looks like you did everything right.
I don't know what to suggest you except as remove this Qt installation at all, reinstall it and try to compile an example again.
Yes, everything except maybe trying to compile the example from the Qt command prompt. Seems it is missing the include and lib dirs.

jjbabu
8th April 2009, 08:06
Hi talk2amulya,
this is my make file:


################################################## ###########################
# Makefile for building: hello
# Generated by qmake (2.01a) (Qt 4.4.3) on: Tue Apr 7 17:43:37 2009
# Project: hello.pro
# Template: app
# Command: c:\Qt\4.4.3\bin\qmake.exe -win32 -o Makefile hello.pro
################################################## ###########################

first: all
install: debug-install release-install
uninstall: debug-uninstall release-uninstall
MAKEFILE = Makefile
QMAKE = c:\Qt\4.4.3\bin\qmake.exe
DEL_FILE = del
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
COPY = copy /y
COPY_FILE = $(COPY)
COPY_DIR = xcopy /s /q /y /i
INSTALL_FILE = $(COPY_FILE)
INSTALL_PROGRAM = $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
DEL_FILE = del
SYMLINK =
DEL_DIR = rmdir
MOVE = move
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
SUBTARGETS = \
debug \
release

debug: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug
debug-make_default: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug
debug-make_first: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug first
debug-all: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug all
debug-clean: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug clean
debug-distclean: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug distclean
debug-install: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug install
debug-uninstall: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug uninstall
release: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release
release-make_default: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release
release-make_first: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release first
release-all: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release all
release-clean: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release clean
release-distclean: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release distclean
release-install: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release install
release-uninstall: $(MAKEFILE).Release FORCE
$(MAKE) -f $(MAKEFILE).Release uninstall

Makefile: hello.pro ../.qmake.cache ../mkspecs/win32-g++/qmake.conf ../mkspecs/features/exclusive_builds.prf \
../mkspecs/features/default_pre.prf \
../mkspecs/features/win32/default_pre.prf \
../.qmake.cache \
../mkspecs/qconfig.pri \
../mkspecs/features/qt_functions.prf \
../mkspecs/features/qt_config.prf \
../mkspecs/features/debug.prf \
../mkspecs/features/debug_and_release.prf \
../mkspecs/features/default_post.prf \
../mkspecs/features/win32/rtti.prf \
../mkspecs/features/win32/exceptions.prf \
../mkspecs/features/win32/stl.prf \
../mkspecs/features/shared.prf \
../mkspecs/features/warn_on.prf \
../mkspecs/features/qt.prf \
../mkspecs/features/win32/thread.prf \
../mkspecs/features/moc.prf \
../mkspecs/features/win32/windows.prf \
../mkspecs/features/resources.prf \
../mkspecs/features/uic.prf \
../mkspecs/features/yacc.prf \
../mkspecs/features/lex.prf \
c:/Qt/4.4.3/lib/qtmaind.prl
$(QMAKE) -win32 -o Makefile hello.pro
..\mkspecs\features\exclusive_builds.prf:
..\mkspecs\features\default_pre.prf:
..\mkspecs\features\win32\default_pre.prf:
..\.qmake.cache:
..\mkspecs\qconfig.pri:
..\mkspecs\features\qt_functions.prf:
..\mkspecs\features\qt_config.prf:
..\mkspecs\features\debug.prf:
..\mkspecs\features\debug_and_release.prf:
..\mkspecs\features\default_post.prf:
..\mkspecs\features\win32\rtti.prf:
..\mkspecs\features\win32\exceptions.prf:
..\mkspecs\features\win32\stl.prf:
..\mkspecs\features\shared.prf:
..\mkspecs\features\warn_on.prf:
..\mkspecs\features\qt.prf:
..\mkspecs\features\win32\thread.prf:
..\mkspecs\features\moc.prf:
..\mkspecs\features\win32\windows.prf:
..\mkspecs\features\resources.prf:
..\mkspecs\features\uic.prf:
..\mkspecs\features\yacc.prf:
..\mkspecs\features\lex.prf:
c:\Qt\4.4.3\lib\qtmaind.prl:
qmake: qmake_all FORCE
@$(QMAKE) -win32 -o Makefile hello.pro

qmake_all: FORCE

make_default: debug-make_default release-make_default FORCE
make_first: debug-make_first release-make_first FORCE
all: debug-all release-all FORCE
clean: debug-clean release-clean FORCE
distclean: debug-distclean release-distclean FORCE
-$(DEL_FILE) Makefile

debug-mocclean: $(MAKEFILE).Debug
$(MAKE) -f $(MAKEFILE).Debug mocclean
release-mocclean: $(MAKEFILE).Release
$(MAKE) -f $(MAKEFILE).Release mocclean
mocclean: debug-mocclean release-mocclean

debug-mocables: $(MAKEFILE).Debug
$(MAKE) -f $(MAKEFILE).Debug mocables
release-mocables: $(MAKEFILE).Release
$(MAKE) -f $(MAKEFILE).Release mocables
mocables: debug-mocables release-mocables
FORCE:

$(MAKEFILE).Debug: Makefile
$(MAKEFILE).Release: Makefile

talk2amulya
8th April 2009, 09:32
ok, so if you look closely..u have around the end some .prf file entries and a prl file entry..this prl file has some references to prf files..now, two of the prf file it mentions are missing in the prf entries your make file have..those prf files are


mkspecs\features\win32\embed_manifest_exe.prf:
mkspecs\features\win32\embed_manifest_dll.prf:

now going thru these files, i found that it does check for VS2005/VS2008..i m not sure if it'll solve your issue, but u can try manually adding these prf file entries in your make file's prf entries and run that make file..also go through your own prl file..maybe it doesnt have entries that mine has..path to prl file is $(QTDIR)/lib/qtmaind.prl ..

talk2amulya
8th April 2009, 09:39
also, what is the value of QMAKESPEC in your Qt command prompt?

jjbabu
8th April 2009, 10:45
my QMAKESPEC set to:

QMAKESPEC set to win32-g++.

can u explain clearly what i have to do with below files.


mkspecs\features\win32\embed_manifest_exe.prf:
mkspecs\features\win32\embed_manifest_dll.prf:

talk2amulya
8th April 2009, 10:54
just add those in between ur various prf file entries and did u check your prl file?

jjbabu
8th April 2009, 11:02
just now i checked my prl file file it contains below stuff:


QMAKE_PRL_BUILD_DIR = C:\Qt\4.4.3\src\winmain
QMAKE_PRO_INPUT = winmain.pro
QMAKE_PRL_TARGET = libqtmaind
QMAKE_PRL_DEFINES = QT_THREAD_SUPPORT
QMAKE_PRL_CONFIG = lex yacc warn_on debug uic resources incremental_off windows debug DebugBuild Debug build_pass warn_on link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header debug stl exceptions rtti dist-config large-config medium-config minimal-config small-config full-config build_all debug incremental create_prl link_prl depend_includepath QTDIR_build debug DebugBuild Debug build_pass staticlib warn_on png zlib qt_install_headers qt warn_on depend_includepath qmake_cache target_qt debug_and_release static zlib debug DebugBuild Debug build_pass no_autoqmake staticlib static moc thread
QMAKE_PRL_VERSION = 4
QMAKE_PRL_LIBS =


So as per ur last post i have to add those 2.prf files to my make file manualy and i have to run application.am i right?

talk2amulya
8th April 2009, 11:11
umm..not really..ur prl file doesnt have those entries..this is strange

spirit
8th April 2009, 11:20
try to install Qt in another directory.