Weird issue during the project building[SOLVED]



  • Hello!
    I have a really strange issue with Qt Creator. During the project design I created three widgets: First, secondFrom and MainWindow.
    So, the problem appears only when compiler is trying to build the widget with the name "First" - compiler can't find any headers, such as QWidget, QVariant etc.
    But, if in the project is no the widget with the name "First", there is no issues during the building. My question is: What's wrong with Qt Creator?

    Here is the screenshot: http://www.freeimagehosting.net/5kjnv

    p.s. On the screenshot are only two widgets. But it doesn't matter at all.



  • You added the proper modules to your project files?

    @
    CONFIG += core
    gui
    etc, etc...
    @



  • Thank you for your answer.

    Yes, I did that. But still, it doesn't work. And, as I understand right, *.pro file is generated automatically during the project creation. Am I right?



  • Yes, but you should add the proper config to them, is a generical one.

    "Check this documentation":http://developer.qt.nokia.com/doc/qt-4.8/qmake-project-files.html



  • According to the link which you posted, core and gui are included by default. Please, have a look at my .pro file below:
    @#-------------------------------------------------

    Project created by QtCreator 2012-01-30T12:42:07

    #-------------------------------------------------
    CONFIG += qt
    QT += core gui

    TARGET = MultiPages
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp
    firstform.cpp
    first.cpp

    HEADERS += mainwindow.h
    firstform.h
    first.h

    FORMS += mainwindow.ui
    firstform.ui
    first.ui
    @

    Here is the compiler output:
    @13:45:10: Running build steps for project MultiPages...
    13:45:10: Configuration unchanged, skipping qmake step.
    13:45:10: Starting: "E:\QtSDK\mingw\bin\mingw32-make.exe"
    e:\qtsdk\desktop\qt\4.7.4\mingw\bin\qmake.exe -spec ....\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++ -o Makefile MultiPages.pro
    E:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory E:/QT_playing/MultiPages' e:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\uic.exe first.ui -o ui_first.h g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\first.o first.cpp E:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 first.h -o debug\moc_first.cpp g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_first.o debug\moc_first.cpp g++ -mthreads -Wl,-subsystem,windows -o debug\MultiPages.exe debug/main.o debug/mainwindow.o debug/firstform.o debug/first.o debug/moc_mainwindow.o debug/moc_firstform.o debug/moc_first.o -L"e:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib g++ -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN first.cpp all -o first mingw32-make.exe[1]: Leaving directoryE:/QT_playing/MultiPages'
    In file included from first.cpp:1:
    first.h:4:19: error: QWidget: No such file or directory
    In file included from first.cpp:2:
    ui_first.h:13:27: error: QtCore/QVariant: No such file or directory
    ui_first.h:14:25: error: QtGui/QAction: No such file or directory
    ui_first.h:15:30: error: QtGui/QApplication: No such file or directory
    ui_first.h:16:30: error: QtGui/QButtonGroup: No such file or directory
    ui_first.h:17:29: error: QtGui/QHeaderView: No such file or directory
    ui_first.h:18:25: error: QtGui/QWidget: No such file or directory
    In file included from first.cpp:1:
    first.h:11: error: expected class-name before '{' token
    first.h:12: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
    first.h:14: error: expected ';' before 'public'
    In file included from first.cpp:2:
    ui_first.h:22: error: expected constructor, destructor, or type conversion before 'class'
    g++: all: No such file or directory
    mingw32-make.exe[1]: *** [first] Error 1
    mingw32-make.exe: *** [debug] Error 2
    13:45:14: The process "E:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project MultiPages (target: Desktop)
    When executing build step 'Make'@



  • And in this one, I only removed the widget with the name "first" and replace it with the widget with the name "Form":
    @#-------------------------------------------------

    Project created by QtCreator 2012-01-30T12:42:07

    #-------------------------------------------------
    CONFIG += qt
    QT += core gui

    TARGET = MultiPages
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp
    firstform.cpp
    form.cpp

    HEADERS += mainwindow.h
    firstform.h
    form.h

    FORMS += mainwindow.ui
    firstform.ui
    form.ui
    @

    Pretty the same project, but the name is different.
    That one is compiled and can be run.

    Here is the compiler output:
    @13:38:18: Running build steps for project MultiPages...
    13:38:18: Configuration unchanged, skipping qmake step.
    13:38:18: Starting: "E:\QtSDK\mingw\bin\mingw32-make.exe"
    e:\qtsdk\desktop\qt\4.7.4\mingw\bin\qmake.exe -spec ....\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++ -o Makefile MultiPages.pro
    E:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory E:/QT_playing/MultiPages' e:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\uic.exe form.ui -o ui_form.h g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\form.o form.cpp E:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 form.h -o debug\moc_form.cpp g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_form.o debug\moc_form.cpp g++ -mthreads -Wl,-subsystem,windows -o debug\MultiPages.exe debug/main.o debug/mainwindow.o debug/firstform.o debug/form.o debug/moc_mainwindow.o debug/moc_firstform.o debug/moc_form.o -L"e:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib mingw32-make.exe[1]: Leaving directoryE:/QT_playing/MultiPages'
    13:38:22: The process "E:\QtSDK\mingw\bin\mingw32-make.exe" exited normally.@



  • Try to completely rebuild the project, please.
    There are menu and context menu entries you can call.



  • Yep, I tried. Result is the same.



  • Erm... the last output you posted here (that one right before my first comment) does not contain any errors...



  • [quote author="Volker" date="1327930863"]Erm... the last output you posted here (that one right before my first comment) does not contain any errors...[/quote]

    I meant the output with the errors. Every time, when I tried to add the widget with the name "First", I get an error while building the project. It's weird...

    But if the name will be "Firstttt" etc. it works fine. As before, the question is, why or what's wrong with the name "First"?



  • Can you put that project in a ZIP somewhere to download? Please only the sources (.h, .cpp, .ui) and the project file (.pro), no generated files (.o, moc_.cpp, ui_*.h) and no executables.



  • Yes, sure. Here the link: http://students.oamk.fi/~t9nidm00/MultiPages.zip
    BTW, I'll appreciate any suggestions about the code inside. Yes, it's not a real project, only playing with Qt. But I would like to know someone's opinion about working without QStackedWidget =)



  • First the cure:
    Rename first.h, first.cpp and first.ui to something different, eg. myfirst.h, myfirst.cpp and myfirst.ui.

    Second the explanation:
    You (and I) ran into a very subtle trick of qmake's makefile generation. qmake always generates a target "first" which is nothing else than an alias to target "all". Additionally, the makefile contains some magic rules that describe how to compile a source file into some object file, probably even builtin rules. Unfortunately, caused by the target first, these rules apply to the source file first.cpp, eventually leading to that crippled compiler call.

    Unfortunately, there is no other solution than renaming your source files. So, the big rule is:

    Never put any file named first.xxx into a qmake based project!



  • Wow, you never gonna sleep without known anything new...



  • BTW
    To demonstrate that it's actually the first target in the Makefile, take your original project (using first.xxx), open the Makefile in a text editor of your choice, search for a line "first: all" and change that to "first-xxx: all" and call make. It will run without problems :)



  • Thank you very much!
    But what about the code inside of .zip? Could you, please, comment it? I mean, mainwindow.cpp and other guys, excluding first.cpp and first.h.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.