PDA

View Full Version : QtGui/QApplication: No such file or directory



codeslicer
7th July 2009, 15:42
So, recently Nokia released QtSingleApplication (http://www.qtsoftware.com/products/appdev/add-on-products/catalog/4/Utilities/qtsingleapplication/) under LGPL (found in Qt Solutions). So, I downloaded the .zip file, unzipped it, and copied it to $QTDIR\src\qtsingleapplication. Then, due to some limitations of LGPL, I open Command Prompt, cd'd to that directory, and ran "configure.bat -library", ran qmake, and then make.

In main.cpp I have a QtSingleApplication object instead of QApplication, so I put "#include <QtSingleApplication>" at the top.

So now in Qt Creator, everything seems good - Qt Creator seems to recognize the existence of QtGui/QApplication. But the compiler doesn't: :(


In file included from c:/Qt/4.5/qt/src/QtSingleApplication/src/QtSingleApplication.cpp:48:
c:/Qt/4.5/qt/src/QtSingleApplication/src/qtsingleapplication.h:48:30: QtGui/QApplication: No such file or directory
In file included from c:/Qt/4.5/qt/src/QtSingleApplication/src/QtSingleApplication.cpp:48:
c:/Qt/4.5/qt/src/QtSingleApplication/src/qtsingleapplication.h:69: error: expected class-name before '{' token

...


And it goes on with errors like that, it basically seems like it can't find the Qt includes, but my environment variables are all good. Any ideas?

~codeslicer

wysota
7th July 2009, 16:16
How does you project file look like?

codeslicer
7th July 2009, 16:56
This is my project file:


include(C:\Qt\4.5\qt\src\qtsingleapplication\src\q tsingleapplication.pri)

TEMPLATE = app
QT += gui \
core \
network
CONFIG += qt \
warn_on \
resources \
debug
DESTDIR = bin
OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build
SOURCES += src/main.cpp \
src/mainwindow.cpp \
src/about.cpp \
src/settings.cpp \
src/parser.cpp
HEADERS += src/mainwindow.h \
src/about.h \
src/settings.h \
src/parser.h
FORMS += ui/mainwindow.ui \
ui/about.ui
RESOURCES += res/main.qrc
RC_FILE += src/main.rc


And then qtsingleapplication.pri is like this:


include(../common.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
QT *= network

qtsingleapplication-uselib:!qtsingleapplication-buildlib {
LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME
} else {
SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp
HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h
}

win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT
else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT
}


And common.pri:


infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib
TEMPLATE += fakelib
QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-2.6)
TEMPLATE -= fakelib
QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib
unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR

codeslicer
7th July 2009, 23:36
Well, Google ended up being the savior. Apparently it's a compiler bug as the Include path wasn't included in the compilation of the Solution. So I had to manually edit the Makefile, as shown in a comment by Brett in the end of this page: http://labs.trolltech.com/blogs/2009/03/27/new-and-last-qtanimationframework-solution/

duthils
9th December 2011, 15:29
I also got this error after modifying the qtsingleapplication.cpp file.

mingw32-make thought the file QtSingleApplication was a binary compiled from qtsingleapplication.cpp and, because the .cpp file was newer than the "binary", make used its implicit rules to recompile the "binary" from source. Hence the lack of include flags in the compilation command and the inaccessible header files.

Solved it with a "touch QtSingleApplication".