Results 1 to 7 of 7

Thread: Make environement problem: `Qt' undeclared (first use in this function)

  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Make environement problem: `Qt' undeclared (first use in this function)

    Hi

    I've been using Qt Creator for a while now and yesterday I created a new shared library using the Qt Creator wizard, but the compilation of the library doesn't want to get through compilation.

    The error messages are below:

    Qt Code:
    1. In file included from c:/Tools/Qt/2009.02/qt/include/QtCore/qnamespace.h:1,
    2. from c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:45,
    3. from c:/Tools/Qt/2009.02/qt/include/QtCore/qobjectdefs.h:1,
    4. from c:/Tools/Qt/2009.02/qt/include/QtGui/../../src/gui/kernel/qwindowdefs.h:45,
    5. from c:/Tools/Qt/2009.02/qt/include/QtGui/qwindowdefs.h:1,
    6. from c:/Tools/Qt/2009.02/qt/include/QtGui/../../src/gui/kernel/qwidget.h:45,
    7. from c:/Tools/Qt/2009.02/qt/include/QtGui/qwidget.h:1,
    8. from c:/Tools/Qt/2009.02/qt/include/QtGui/QWidget:1,
    9. from include\QtObserverLibrary\ObserverCollectionDetailsWidget.h:4:
    10. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:54: error: syntax error before "namespace"
    11. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:58: error: syntax error before '{' token
    12. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:135: warning: return type defaults to `int'
    13. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h: In function `Q_DECLARE_FLAGS':
    14. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: error: `Qt' undeclared (first use in this function)
    15. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: error: (Each undeclared identifier is reported only once
    16. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: error: for each function it appears in.)
    17. c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: confused by earlier errors, bailing out
    18. mingw32-make[1]: Leaving directory `D:/ScinericSoftware/Products/QtObserverLibrary/trunk'
    19. mingw32-make: Leaving directory `D:/ScinericSoftware/Products/QtObserverLibrary/trunk'
    20. mingw32-make[1]: *** [tmp/ObserverCollectionDetailsWidget.o] Error 1
    21. mingw32-make: *** [debug] Error 2
    22. Exited with code 2.
    To copy to clipboard, switch view to plain text mode 

    And below is my .pro file:

    qmake Code:
    1. CONFIG += qt dll ordered
    2. QT += xml
    3.  
    4. TARGET = QtObserverLibrary
    5. TEMPLATE = lib
    6.  
    7. DEFINES += QTOBSERVERLIBRARY_LIBRARY
    8.  
    9. DEPENDPATH += include/QtObserverLibrary \
    10. source
    11. INCLUDEPATH += include/QtObserverLibrary \
    12. source
    13.  
    14. win32:UI_HEADERS_DIR = include/QtObserverLibrary
    15. win32:DLLDESTDIR = bin
    16. win32:DESTDIR = bin
    17. win32:OBJECTS_DIR = tmp
    18. win32:MOC_DIR = tmp
    19. win32:RCC_DIR = tmp
    20. win32:UI_DIR = tmp
    21.  
    22. + Some headers, forms and sources
    To copy to clipboard, switch view to plain text mode 

    Maybe I'm missing something simple, but I just can't seem to get it working. Shouldn't the Qt environment exposed to make by default?

    Thanks for any inputs,
    Regards,
    Jaco
    Last edited by wysota; 24th June 2009 at 12:11.

  2. #2
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Make environement problem: `Qt' undeclared (first use in this function)

    Just a wild guess: Maybe there's something wrong in a header file included before <QWidget>. Put #include <QWidget> on the first line of ObserverCollectionDetailsWidget.h and try again.

  3. #3
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Make environement problem: `Qt' undeclared (first use in this function)

    Hi

    Thanks for the guess, but nope its not the problem:

    Qt Code:
    1. #ifndef OBSERVERCOLLECTIONDETAILSWIDGET_H
    2. #define OBSERVERCOLLECTIONDETAILSWIDGET_H
    3.  
    4. #include <QWidget>
    To copy to clipboard, switch view to plain text mode 

    Its not related to a specific file, its related to the project setup I believe.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Make environement problem: `Qt' undeclared (first use in this function)

    What happens if you remove "CONFIG+=qt" from the project? Also do you have a class or namespace called Qt in your own code?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Make environement problem: `Qt' undeclared (first use in this function)

    1) Removing the Config += qt line does not help, no.
    2) I'm sure I don't have any Qt namespace in my project.

    Below is the gcc call that is generated by Qt Creator:

    Qt Code:
    1. gcc -c -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQTOBSERVERLIBRARY_LIBRARY -DQT_DLL -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Tools\Qt\2009.02\qt\include\QtCore" -I"c:\Tools\Qt\2009.02\qt\include\QtGui" -I"c:\Tools\Qt\2009.02\qt\include\QtXml" -I"c:\Tools\Qt\2009.02\qt\include" -I"include\QtObserverLibrary" -I"source" -I"c:\Tools\Qt\2009.02\qt\include\ActiveQt" -I"tmp" -I"include\QtObserverLibrary" -I"c:\Tools\Qt\2009.02\qt\mkspecs\win32-g++" -o tmp\ObserverCollectionDetailsWidget.o include\QtObserverLibrary\ObserverCollectionDetailsWidget.h
    To copy to clipboard, switch view to plain text mode 

    And below is the gcc call from a different project which works fine:

    Qt Code:
    1. 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"c:\Tools\Qt\2009.02\qt\include\QtCore" -I"c:\Tools\Qt\2009.02\qt\include\QtGui" -I"c:\Tools\Qt\2009.02\qt\include" -I"c:\Tools\Qt\2009.02\qt\include\ActiveQt" -I"debug" -I"." -I"c:\Tools\Qt\2009.02\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
    To copy to clipboard, switch view to plain text mode 

    The only difference that I can see is -DQT_NEEDS_QMAIN. But adding this define to the shared library project does not resolve anything.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Make environement problem: `Qt' undeclared (first use in this function)

    Both lines look fine to me. The error has to be in your source file. Try deleting it and typing in the contents manually again (don't paste it as you could paste some non-readable character).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Make environement problem: `Qt' undeclared (first use in this function)

    Thanks for the reply again Wysota.

    I figured it out, and it was my mistake. I accidentally had all my sources under HEADERS += and all my headers under SOURCES +=.

    Thanks again,
    Regards,
    Jaco

Similar Threads

  1. Problem with make (can't call moc.exe)
    By johnny_sparx in forum Installation and Deployment
    Replies: 4
    Last Post: 14th September 2007, 13:02
  2. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  3. Unable to execute in Debug Mode
    By Kapil in forum Installation and Deployment
    Replies: 38
    Last Post: 5th April 2006, 07:27
  4. lQtGuid4 error - Compiler setting problem
    By Kapil in forum Installation and Deployment
    Replies: 7
    Last Post: 10th February 2006, 09:30
  5. Qt 4.1 and KDE 3.5.1 on OSX 10.2.8
    By Ptero-4 in forum Installation and Deployment
    Replies: 6
    Last Post: 6th February 2006, 02:44

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.