Page 1 of 2 12 LastLast
Results 1 to 20 of 31

Thread: compilation error

  1. #1
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default compilation error

    after installing qt,i just for checking i compiled
    Qt Code:
    1. #include <QApplication>
    2. #include <QLabel>
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QLabel *label = new QLabel("Hello Qt!");
    7. label->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compilation error

    what kind of application did you create? Qt Console or Qt Gui?

  3. #3
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    QtGui only.
    i just want to check whether "hello qt" label will be displayed or not.

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: compilation error

    What is in your .pro file?
    I'm a rebel in the S.D.G.

  5. #5
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    this is my .pro file:
    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .

    # Input
    SOURCES += hello.cpp

  6. #6
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: compilation error

    Try adding QT += gui to you .pro file.
    I'm a rebel in the S.D.G.

  7. #7
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compilation error

    u havent included QtGui..QApplication and QLabel are both part of it

  8. #8
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    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...

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compilation error

    Quote Originally Posted by lyuts View Post
    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. #10
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compilation error

    Quote Originally Posted by jjbabu View Post
    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?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  11. #11
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: compilation error

    Quote Originally Posted by spirit View Post
    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.
    I'm a rebel in the S.D.G.

  12. #12
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    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.

  13. #13
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compilation error

    ask you again: did you build Qt for VS2005?
    do you use only minGW or VS2005 too?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  14. #14
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    i have not build qt with VS2005.i am directly using qt.

  15. #15
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compilation error

    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?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  16. #16
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    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...

  17. #17
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compilation error

    looks like you did right steps.
    can you show us what returns this command echo %QTDIR% in "QT4.4.3 command prompt".
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  18. #18
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    it is showing like below:

    C:\Qt\4.4.3

  19. #19
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compilation error

    are u interested to see any of my system variables and user variables?

  20. #20
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compilation error

    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  5. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.