Results 1 to 6 of 6

Thread: some error in my first program

  1. #1

    Question some error in my first program

    It was maybe caused by setting on include path.

    my code is --

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


    And after running "mingw32-make", following error msg came in:

    mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/wp_Cpp/hello'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../Qt/4.4.0/include/QtCore' -I'../../Qt/4.
    4.0/include/QtCore' -I'../../Qt/4.4.0/include/QtGui' -I'../../Qt/4.4.0/include/QtGui' -I'../../Qt/4.4.0/include' -I'.' -I'c:/Qt/4.4.0/include/ActiveQt' -I'debug' -I'.' -I'../../Qt/4.4.0/mkspecs/win32-
    g++' -o debug/hello.o hello.cpp
    In file included from ../../Qt/4.4.0/include/QtCore/qglobal.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:47,
    from ../../Qt/4.4.0/include/QtCore/qnamespace.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:47,
    from ../../Qt/4.4.0/include/QtCore/qobjectdefs.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:49,
    from ../../Qt/4.4.0/include/QtCore/qobject.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:47,
    from ../../Qt/4.4.0/include/QtCore/qcoreapplication.h:1,
    from ../../Qt/4.4.0/include/Qt/../../src/gui/kernel/qapplication.h:47,
    from ../../Qt/4.4.0/include/Qt/QApplication.h:1,
    from hello.cpp:1:
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:47:20: stddef.h: No such file or directory
    In file included from ../../Qt/4.4.0/include/QtCore/qglobal.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:47,
    from ../../Qt/4.4.0/include/QtCore/qnamespace.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:47,
    from ../../Qt/4.4.0/include/QtCore/qobjectdefs.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:49,
    from ../../Qt/4.4.0/include/QtCore/qobject.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:47,
    from ../../Qt/4.4.0/include/QtCore/qcoreapplication.h:1,
    from ../../Qt/4.4.0/include/Qt/../../src/gui/kernel/qapplication.h:47,
    from ../../Qt/4.4.0/include/Qt/QApplication.h:1,
    from hello.cpp:1:
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1850: error: variable `qMalloc' definition is marked dllimport.
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1850: error: `size_t' was not declared in this scope
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1852: error: `size_t' has not been declared
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1852: error: ISO C++ forbids declaration of `size' with no type
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1853: error: `size_t' has not been declared
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1853: error: ISO C++ forbids declaration of `n' with no type
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1854: error: `size_t' has not been declared
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/global/qglobal.h:1854: error: ISO C++ forbids declaration of `n' with no type
    In file included from ../../Qt/4.4.0/include/QtCore/qbytearray.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qstring.h:48,
    from ../../Qt/4.4.0/include/QtCore/qstring.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:50,
    from ../../Qt/4.4.0/include/QtCore/qobject.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:47,
    from ../../Qt/4.4.0/include/QtCore/qcoreapplication.h:1,
    from ../../Qt/4.4.0/include/Qt/../../src/gui/kernel/qapplication.h:47,
    from ../../Qt/4.4.0/include/Qt/QApplication.h:1,
    from hello.cpp:1:
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:50:20: string.h: No such file or directory
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:51:20: stdarg.h: No such file or directory
    In file included from ../../Qt/4.4.0/include/QtCore/qbytearray.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qstring.h:48,
    from ../../Qt/4.4.0/include/QtCore/qstring.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:50,
    from ../../Qt/4.4.0/include/QtCore/qobject.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:47,
    from ../../Qt/4.4.0/include/QtCore/qcoreapplication.h:1,
    from ../../Qt/4.4.0/include/Qt/../../src/gui/kernel/qapplication.h:47,
    from ../../Qt/4.4.0/include/Qt/QApplication.h:1,
    from hello.cpp:1:
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h: In function `uint qstrlen(const char*)':
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:70: error: `strlen' undeclared (first use this function)
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:70: error: (Each undeclared identifier is reported only once for each function it appears in.)
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h: In function `int qstrncmp(const char*, const char*, uint)':
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:93: error: `strncmp' undeclared (first use this function)
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h: At global scope:
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:100: error: `size_t' has not been declared
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:100: error: `va_list' has not been declared
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:100: error: ISO C++ forbids declaration of `n' with no type
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:100: error: ISO C++ forbids declaration of `ap' with no type
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:101: error: `size_t' has not been declared
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:101: error: ISO C++ forbids declaration of `n' with no type
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h: In function `bool operator==(const QByteArray&, const QByteArray&)':
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qbytearray.h:495: error: `memcmp' undeclared (first use this function)
    In file included from ../../Qt/4.4.0/include/QtCore/qstring.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:50,
    from ../../Qt/4.4.0/include/QtCore/qobject.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:47,
    from ../../Qt/4.4.0/include/QtCore/qcoreapplication.h:1,
    from ../../Qt/4.4.0/include/Qt/../../src/gui/kernel/qapplication.h:47,
    from ../../Qt/4.4.0/include/Qt/QApplication.h:1,
    from hello.cpp:1:
    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qstring.h:62:22: string: No such file or directory
    In file included from ../../Qt/4.4.0/include/QtCore/qstring.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:50,
    from ../../Qt/4.4.0/include/QtCore/qobject.h:1,
    from ../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel

    ...............


    ../../Qt/4.4.0/include/QtCore/../../src/corelib/tools/qvector.h:376: error: `qMalloc' cannot be used as a function
    mingw32-make[1]: *** [debug/hello.o] Error 1
    mingw32-make[1]: Leaving directory `C:/wp_Cpp/hello'
    mingw32-make: *** [debug] Error 2

  2. #2
    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: some error in my first program

    How did you install Qt? Show us your installation steps.
    Last edited by lyuts; 9th June 2008 at 18:21. Reason: spelling error
    I'm a rebel in the S.D.G.

  3. #3

    Smile Re: some error in my first program

    hi

    Firstly, I downloaded 'qt-win-opensource-4.4.0-mingw.exe' and MinGW 3.4.2, and then ran them.

    Then I set following env variables:

    PATH = C:\MinGW_Qt\bin;C:\MinGW_Qt\libexec\gcc\mingw32\3. 4.2;c:\mysql\bin;c:\ruby\bin;C:\Qt\4.4.0\bin

    INCLUDE = C:\MinGW_Qt\include;C:\Qt\4.4.0\include

    LIB = C:\MinGW_Qt\lib;C:\Qt\4.4.0\lib

    QTDIR = C:\Qt\4.4.0

    Then I went Start Menu and run 'Qt 4.4.0 (Build Debug Libraries)'. It seemed that the command ran without any error.

    That's all.

    Thanks!

  4. #4

    Unhappy Re: some error in my first program

    Who knows what is wrong?

  5. #5

    Default Re: some error in my first program

    hey

    I intalled a MinGW5.1.4 instead of 3.4.2, and ran 'make', that was OK.

    but I could not image the reason.

  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: some error in my first program

    This is how i usually install Qt.
    1. Install MinGW v3.4.2
    2. Run Qt installer
    3. go to QTDIR
    4. run configure.exe (with params that i nedd)
    5. run mingw32-make
    6. run mingw32-make install (probably not needed, but i run it)

    an Qt is ready.
    I'm a rebel in the S.D.G.

Similar Threads

  1. Replies: 19
    Last Post: 21st January 2008, 09:13
  2. Replies: 5
    Last Post: 29th October 2007, 22:49
  3. Version setting in QT Program
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 24th October 2007, 12:07
  4. In what order do you create program pieces?
    By Backslash in forum Newbie
    Replies: 2
    Last Post: 15th July 2007, 18:18
  5. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19

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.