Results 1 to 5 of 5

Thread: Qt failing to compile claiming "fatal error: QObject: No such file or directory"

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt failing to compile claiming "fatal error: QObject: No such file or directory"

    Hi!

    I have a project developed in Qt 4.8 for Embedded Linux and Linux that compiles fine. Now I'm trying to compile it in Qt 5.5.1 in Windows 7 and I got a problem I'm being unable to solve: each time I try to compile it, I get the error

    Qt Code:
    1. C:\Qt\Qt5.5\5.5\mingw492_32\bin\uic.exe interface\dialogs\alphanumerickeyboard.ui -o build\uis\ui_alphanumerickeyboard.h
    2. g++ -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DV_SERGIPETECH_0=0x100 -DV_SERGIPETECH_1=0x101 -DV_UNILA_0=0x110 -DGENERAL_VERSION_NUMBER=V_UNILA_0 -DAPP_VERSION=\"\" -DMAIN_CLOCK=1000 -DSCREENSAVER_SIMPLE_MODE -DCENTER_CONTROLLER -DPERIODIC_WIDGETS_UPDATE -DSAVE_ENTIRE_PQ -DDEFAULT_THEME_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../..\main_projects\interface\theme"' -DDEFAULT_DATA_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../..\main_projects\interface\data"' -DDEFAULT_TRANSLATION_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/translations"' -DDEFAULT_SCREENSHOT_PATH='"C:\Users\Administrador\Imagens\screenshots"' -DDEFAULT_RECORD_DIR='"C:\Users\Administrador\Documentos\TEMP\LogsRE8000"' -DDEFAULT_PENDRIVE_DIR='"C:\Users\Administrador\Documentos\TEMP\PendriveRE8000"' -DDEFAULT_VERSION_FILE_PATH='"C:\Users\Administrador\Documentos\TEMP\version.info"' -DCALIBRATION_FILE='"C:\Users\Administrador\Documentos\TEMP\caltouchpoints"' -DDEFAULT_ETC_PATH='"C:\Users\Administrador\Documentos\TEMP"' -DDESKTOP -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN qtextension/qcycleimagebutton.cpp -o qtextension/QCycleImageButton
    3. In file included from qtextension/qcycleimagebutton.cpp:1:0:
    4. qtextension/qcycleimagebutton.hpp:4:19: fatal error: QObject: No such file or directory
    5. #include <QObject>
    6. ^
    7. compilation terminated.
    To copy to clipboard, switch view to plain text mode 

    for the same file, which starts as such:

    Qt Code:
    1. #ifndef QCYCLEIMAGEBUTTON_H_
    2. #define QCYCLEIMAGEBUTTON_H_
    3.  
    4. #include <QObject>
    5. #include <QAbstractButton>
    6. #ifdef DESKTOP
    7. #include <QtDesigner/QDesignerExportWidget>
    8. #else
    9. #define QDESIGNER_WIDGET_EXPORT
    10. #endif
    11.  
    12. #include "interfaceglobal.hpp"
    13.  
    14. class QLabel;
    15. class QImageButtonIllustration;
    16. class QImageSliderIllustration;
    17.  
    18. typedef qint32 button_id;
    19.  
    20. class QDESIGNER_WIDGET_EXPORT QCycleImageButton : public QAbstractButton
    21. {
    22. Q_OBJECT
    To copy to clipboard, switch view to plain text mode 

    I can assure the Qt installation went OK since I created a QWidgets project and it compiled fine. I also checked if there was anything special in the Projects configuration but I couldn't find any problems there.

    I also tried to find solutions to this problem on the web, but nothing helpful was found. Here is my .pro file as for now (minus the .hpp and .cpp includes):

    Qt Code:
    1. QT += core gui xml network
    2. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    3.  
    4. #CONFIG += qwt
    5. #CONFIG += qwtpolar
    6.  
    7. RE8K_REPO = $${PWD}/../../..
    8. RE8K_COMMON = $${RE8K_REPO}/common
    9. RE8K_SDCARD = $${RE8K_REPO}/../../sdcard_files/defaultFiles
    10. RE8K_TRANSLATION = $${RE8K_REPO}/main_projects/interface/translations
    11.  
    12. VERSION = $$system(svn info -r HEAD . | grep 'Changed\ Rev' | cut -b 19-)
    13.  
    14. DEFINES += "GENERAL_VERSION_NUMBER=V_UNILA_0"
    15. DEFINES += APP_VERSION=\\\"$$VERSION\\\"
    16. #DEFINES += CLASSE_A_TEST
    17. #DEFINES += INTERFACE_DEMO #Special for the demo version
    18. DEFINES += MAIN_CLOCK=1000
    19.  
    20. DEFINES += SCREENSAVER_SIMPLE_MODE
    21. #DEFINES += DATASTREAM_THREAD
    22. DEFINES += CENTER_CONTROLLER
    23. DEFINES += PERIODIC_WIDGETS_UPDATE #Enable update by 1 sec of all top level widgets to counter black screen bug
    24. DEFINES += SAVE_ENTIRE_PQ #When selecting one item of a Physical Quantity makes all items be saved in a record
    25. #DEFINES += SAVE_XML_TEST
    26. #DEFINES += XML_WITH_COMMENTS
    27. #DEFINES += RELEASE_VERSION
    28. #DEFINES USE_FULL_CURRENT_RANGE_CONFIG #Enables current range of all 4 channels
    29.  
    30. INCLUDEPATH += $${RE8K_COMMON}/include
    31. INCLUDEPATH += qtextension
    32.  
    33. LIBS += -L$${RE8K_COMMON}/lib #needed for hal, etc.
    34. LIBS += -lQDeviceWatcher
    35.  
    36. CONFIG(debug, debug|release) {
    37. LIBS += -lmLoggerd
    38. }
    39.  
    40. CONFIG(release, debug|release) {
    41. LIBS += -lmLogger
    42. }
    43.  
    44. win32 {
    45. DEFINES += 'DEFAULT_THEME_PATH=\'\"$${RE8K_REPO}\main_projects\interface\theme\"\''
    46. DEFINES += 'DEFAULT_DATA_PATH=\'\"$${RE8K_REPO}\main_projects\interface\data\"\''
    47. DEFINES += 'DEFAULT_TRANSLATION_PATH=\'\"$${RE8K_TRANSLATION}\"\''
    48. DEFINES += 'DEFAULT_SCREENSHOT_PATH=\'\"C:\Users\Administrador\Imagens\screenshots\"\''
    49. DEFINES += 'DEFAULT_RECORD_DIR=\'\"C:\Users\Administrador\Documentos\TEMP\LogsRE8000\"\''
    50. DEFINES += 'DEFAULT_PENDRIVE_DIR=\'\"C:\Users\Administrador\Documentos\TEMP\PendriveRE8000\"\''
    51. DEFINES += 'DEFAULT_VERSION_FILE_PATH=\'\"C:\Users\Administrador\Documentos\TEMP\version.info\"\''
    52. DEFINES += 'CALIBRATION_FILE=\'\"C:\Users\Administrador\Documentos\TEMP\caltouchpoints\"\''
    53. DEFINES += 'DEFAULT_ETC_PATH=\'\"C:\Users\Administrador\Documentos\TEMP\"\''
    54.  
    55. DEFINES += DESKTOP
    56.  
    57. INCLUDEPATH += C:\Qt\Qwt-6.1.2\include
    58. INCLUDEPATH += C:\Qt\QwtPolar-1.1.1\include
    59. INCLUDEPATH += ..\..\..\third_party\mLogger\src
    60. INCLUDEPATH += ..\..\..\third_party\QDeviceWatcher\src
    61.  
    62. LIBS += -LC:\Qt\Qwt-6.1.2\lib
    63. LIBS += -LC:\Qt\QwtPolar-1.1.1\lib
    64.  
    65. TARGET = name_here
    66. }
    To copy to clipboard, switch view to plain text mode 

    Any help appreciated.
    Last edited by Momergil; 29th October 2015 at 16:28.
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt failing to compile claiming "fatal error: QObject: No such file or directory"

    Moving thread up!
    May the Lord be with you. Always.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt failing to compile claiming "fatal error: QObject: No such file or directory"

    Your compiler call doesn't seem to have any of the include paths you've specified.
    Have you tried without any of those?

    Also it might be necessary to escape the \ in the paths, especially in the DEFINES.
    For the DEFINES maybe even better use forward slashes.

    Cheers,
    _

  4. #4
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt failing to compile claiming "fatal error: QObject: No such file or directory"

    Quote Originally Posted by anda_skoa View Post
    Your compiler call doesn't seem to have any of the include paths you've specified.
    Have you tried without any of those?

    Also it might be necessary to escape the \ in the paths, especially in the DEFINES.
    For the DEFINES maybe even better use forward slashes.

    Cheers,
    _
    Thanks anda_skoa for the reply, but I confess I don't know what to do with the comments you gave me appart from the backslash which I put as an attempt to solve the problem (but I already put the back to forward slashes).

    Regarding not having the include paths, yes, that's true: comparing the Output result of compiling the app for Desktop in Linux vs. Windows I get:

    Qt Code:
    1. //Linux
    2. g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DV_SERGIPETECH_0=0x100 -DV_SERGIPETECH_1=0x101 -DV_UNILA_0=0x110 -DGENERAL_VERSION_NUMBER=V_UNILA_0 -DAPP_VERSION=\"335\" -DMAIN_CLOCK=1000 -DSCREENSAVER_SIMPLE_MODE -DCENTER_CONTROLLER -DPERIODIC_WIDGETS_UPDATE -DSAVE_ENTIRE_PQ -DDEFAULT_THEME_PATH='"/home/maiquel/Projects/RE8000/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/theme"' -DDEFAULT_DATA_PATH='"/home/maiquel/Projects/RE8000/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/data"' -DDEFAULT_TRANSLATION_PATH='"/home/maiquel/Projects/RE8000/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/translations"' -DDEFAULT_SCREENSHOT_PATH='"~/Pictures/screenshots"' -DDEFAULT_RECORD_DIR='"/home/maiquel/Documents/TEMP/LogsRE8000"' -DDEFAULT_PENDRIVE_DIR='"/home/maiquel/Documents/TEMP/PendriveRE8000"' -DDEFAULT_VERSION_FILE_PATH='"/home/maiquel/Documents/TEMP/version.info"'
    3. -DCALIBRATION_FILE='"/home/maiquel/Documents/TEMP/caltouchpoints"' -DDEFAULT_ETC_PATH='"/home/maiquel/Documents/TEMP"'
    4. -DDESKTOP -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.5/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.8.5/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5/include/QtNetwork -I/usr/local/Trolltech/Qt-4.8.5/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5/include/QtXml -I/usr/local/Trolltech/Qt-4.8.5/include -I../../../common/include -Iqtextension -I/usr/local/include -I/usr/local/qwt-6.1.0/include -I/usr/local/qwtpolar-1.1.0/include -Ibuild/mocs -Ibuild/uis -o build/objs/qcycleimagebutton.o qtextension/qcycleimagebutton.cpp
    5.  
    6. //Windows
    7. g++ -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DV_SERGIPETECH_0=0x100 -DV_SERGIPETECH_1=0x101 -DV_UNILA_0=0x110 -DGENERAL_VERSION_NUMBER=V_UNILA_0 -DAPP_VERSION=\"\" -DMAIN_CLOCK=1000 -DHAS_GPS -DSCREENSAVER_SIMPLE_MODE -DCENTER_CONTROLLER -DPERIODIC_WIDGETS_UPDATE -DSAVE_ENTIRE_PQ -DDEFAULT_THEME_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/theme"' -DDEFAULT_DATA_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/data"' -DDEFAULT_TRANSLATION_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/translations"' -DDEFAULT_SCREENSHOT_PATH='"C:/Users/Administrador/Imagens/screenshots"' -DDEFAULT_RECORD_DIR='"C:/Users/Administrador/Documentos/TEMP/LogsRE8000"' -DDEFAULT_PENDRIVE_DIR='"C:/Users/Administrador/Documentos/TEMP/PendriveRE8000"' -DDEFAULT_VERSION_FILE_PATH='"C:/Users/Administrador/Documentos/TEMP/version.info"' -DCALIBRATION_FILE='"C:/Users/Administrador/Documentos/TEMP/caltouchpoints"' -DDEFAULT_ETC_PATH='"C:/Users/Administrador/Documentos/TEMP"' -DDESKTOP -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN qtextension/qcycleimagebutton.cpp -o qtextension/QCycleImageButton
    To copy to clipboard, switch view to plain text mode 

    It's easy to see that both the includes of INCLUDEPATH as well as those of the Qt libraries are missing. The funny fact is that they are in the Makefiles!!

    Qt Code:
    1. //Makefile.Release
    2. ...
    3.  
    4. CC = gcc
    5. CXX = g++
    6. DEFINES = -DUNICODE -DV_SERGIPETECH_0=0x100 -DV_SERGIPETECH_1=0x101 -DV_UNILA_0=0x110 -DGENERAL_VERSION_NUMBER=V_UNILA_0 -DAPP_VERSION=\"\" -DMAIN_CLOCK=1000 -DHAS_GPS -DSCREENSAVER_SIMPLE_MODE -DCENTER_CONTROLLER -DPERIODIC_WIDGETS_UPDATE -DSAVE_ENTIRE_PQ -DDEFAULT_THEME_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/theme"' -DDEFAULT_DATA_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/data"' -DDEFAULT_TRANSLATION_PATH='"D:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../main_projects/interface/translations"' -DDEFAULT_SCREENSHOT_PATH='"C:/Users/Administrador/Imagens/screenshots"' -DDEFAULT_RECORD_DIR='"C:/Users/Administrador/Documentos/TEMP/LogsRE8000"' -DDEFAULT_PENDRIVE_DIR='"C:/Users/Administrador/Documentos/TEMP/PendriveRE8000"' -DDEFAULT_VERSION_FILE_PATH='"C:/Users/Administrador/Documentos/TEMP/version.info"' -DCALIBRATION_FILE='"C:/Users/Administrador/Documentos/TEMP/caltouchpoints"' -DDEFAULT_ETC_PATH='"C:/Users/Administrador/Documentos/TEMP"' -DDESKTOP -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN
    7. CFLAGS = -pipe -fno-keep-inline-dllexport -O2 -Wall -Wextra $(DEFINES)
    8. CXXFLAGS = -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads $(DEFINES)
    9. INCPATH = -I. -I..\..\..\common\include -Iqtextension -IC:\Qt\Qwt-6.1.2\include -IC:\Qt\QwtPolar-1.1.1\include -I..\..\..\third_party\mLogger\src -I..\..\..\third_party\QDeviceWatcher\src -IC:\Qt\Qt5.5\5.5\mingw492_32\include -IC:\Qt\Qt5.5\5.5\mingw492_32\include\QtWidgets -IC:\Qt\Qt5.5\5.5\mingw492_32\include\QtGui -IC:\Qt\Qt5.5\5.5\mingw492_32\include\QtANGLE -IC:\Qt\Qt5.5\5.5\mingw492_32\include\QtXml -IC:\Qt\Qt5.5\5.5\mingw492_32\include\QtNetwork -IC:\Qt\Qt5.5\5.5\mingw492_32\include\QtCore -Ibuild\mocs -Ibuild\uis -IC:\Qt\Qt5.5\5.5\mingw492_32\mkspecs\win32-g++
    10. LINKER = g++
    11. LFLAGS = -Wl,-s -Wl,-subsystem,windows -mthreads
    12. LIBS = -lmingw32 -LC:/Qt/Qt5.5/5.5/mingw492_32/lib -lqtmain -lshell32 -LD:/Desenvolvimento/RE8000SW/src/trunk/main_projects/interface/re8k_interface/../../../common/lib -lQDeviceWatcher -lmLogger -LC:/Qt/Qwt-6.1.2/lib -LC:/Qt/QwtPolar-1.1.1/lib -lqwt -lqwtpolar -lQt5Widgets -lQt5Gui -lQt5Xml -lQt5Network -lQt5Core
    13. QMAKE = C:\Qt\Qt5.5\5.5\mingw492_32\bin\qmake.exe
    14.  
    15. ...
    To copy to clipboard, switch view to plain text mode 

    So for some reason although qmake seems to be generating the Makefiles correctly, they are not being correctly obeyed by MinGW when it's called. Any suggestions?
    May the Lord be with you. Always.

  5. #5
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt failing to compile claiming "fatal error: QObject: No such file or directory"

    So far I've done the following:

    I created a new project and started adding each header and source file one by one. I managed to discover some of the files which, once included, would trigger the error. Then I started doing the same for one of those files: including line by line of code.

    What I managed to find was that if I moved the instantiation of a class object to the source file (with the header including the problematic qimagebutton.hpp), the error appears. If I then move back, the error continues and persists till I completely erase the files, deletes the makefiles and rebuild everything again.

    Ultimately I noticed that I was including qimagebutton.hpp indirectly in the same way we include Qt classes: creating a file without extension, putting the include inside and then including the extensionless file in the project: #include <QImageButton>. I decided, then, to remove this adding the file directly and problem solved! (at least so far).

    So, for some reason, MinGW seems to dislike such indirect includes.
    May the Lord be with you. Always.

Similar Threads

  1. Replies: 12
    Last Post: 19th August 2015, 18:50
  2. Replies: 15
    Last Post: 6th March 2015, 13:34
  3. Replies: 2
    Last Post: 20th September 2013, 22:47
  4. "application has encountered a fatal error" on a Necessitas AVD
    By sedi in forum Installation and Deployment
    Replies: 1
    Last Post: 20th May 2012, 20:20
  5. Replies: 9
    Last Post: 20th May 2010, 09:55

Tags for this Thread

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.