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:
Code:
In file included from c:/Tools/Qt/2009.02/qt/include/QtCore/qnamespace.h:1,
from c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:45,
from c:/Tools/Qt/2009.02/qt/include/QtCore/qobjectdefs.h:1,
from c:/Tools/Qt/2009.02/qt/include/QtGui/../../src/gui/kernel/qwindowdefs.h:45,
from c:/Tools/Qt/2009.02/qt/include/QtGui/qwindowdefs.h:1,
from c:/Tools/Qt/2009.02/qt/include/QtGui/../../src/gui/kernel/qwidget.h:45,
from c:/Tools/Qt/2009.02/qt/include/QtGui/qwidget.h:1,
from c
:/Tools
/Qt
/2009.02/qt
/include
/QtGui
/QWidget:1,
from include\QtObserverLibrary\ObserverCollectionDetailsWidget.h:4:
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:54: error: syntax error before "namespace"
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:58: error: syntax error before '{' token
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:135: warning: return type defaults to `int'
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h: In function `Q_DECLARE_FLAGS':
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: error: `Qt' undeclared (first use in this function)
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: error: (Each undeclared identifier is reported only once
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: error: for each function it appears in.)
c:/Tools/Qt/2009.02/qt/include/QtCore/../../src/corelib/global/qnamespace.h:136: confused by earlier errors, bailing out
mingw32-make[1]: Leaving directory `D:/ScinericSoftware/Products/QtObserverLibrary/trunk'
mingw32-make: Leaving directory `D:/ScinericSoftware/Products/QtObserverLibrary/trunk'
mingw32-make[1]: *** [tmp/ObserverCollectionDetailsWidget.o] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
And below is my .pro file:
Code:
CONFIG += qt dll ordered
QT += xml
TARGET = QtObserverLibrary
TEMPLATE = lib
DEFINES += QTOBSERVERLIBRARY_LIBRARY
DEPENDPATH += include/QtObserverLibrary \
source
INCLUDEPATH += include/QtObserverLibrary \
source
win32:UI_HEADERS_DIR = include/QtObserverLibrary
win32:DLLDESTDIR = bin
win32:DESTDIR = bin
win32:OBJECTS_DIR = tmp
win32:MOC_DIR = tmp
win32:RCC_DIR = tmp
win32:UI_DIR = tmp
+ Some headers, forms and sources
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
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.
Re: Make environement problem: `Qt' undeclared (first use in this function)
Hi
Thanks for the guess, but nope its not the problem:
Code:
#ifndef OBSERVERCOLLECTIONDETAILSWIDGET_H
#define OBSERVERCOLLECTIONDETAILSWIDGET_H
#include <QWidget>
Its not related to a specific file, its related to the project setup I believe.
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?
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:
Code:
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
And below is the gcc call from a different project which works fine:
Code:
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
The only difference that I can see is -DQT_NEEDS_QMAIN. But adding this define to the shared library project does not resolve anything.
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).
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