Results 1 to 10 of 10

Thread: strange error in compilation

  1. #1
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default strange error in compilation

    i am having strange error in compilation. I am presenting some part of my header file and output on terminal
    Qt Code:
    1. #ifndef vA_H
    2. #define vA_H
    3.  
    4. //QT4 includes
    5. #include <QObject>
    6.  
    7. //QGIS includes
    8. #include <qgisapp.h>
    9. #include <qgsmaptool.h>
    10. #include <qgsmapcanvas.h>
    11. #include<qgspoint.h>
    12. #include "../qgisplugin.h"
    13. #include<QToolBar>
    14. //#include "vARubberBand.h"
    15.  
    16. //forward declarations
    17.  
    18. //class QToolBar;
    19. class vARubberBand;
    20. /**
    21. * \class Plugin
    22. * \brief [name] plugin for QGIS
    23. * [description]
    24. */
    25. class vA1:public QgsMapTool , public QgisPlugin
    26. {
    27. Q_OBJECT;
    28. public:
    29. vA1(QgisApp * theApplication, QgisIface * theInterface);
    30. //! Destructor
    31. virtual ~vA1();
    32.  
    33. //! inherited from QgsMapTool
    To copy to clipboard, switch view to plain text mode 

    part of output is
    g++ -DHAVE_CONFIG_H -I. -I. -I../../.. -g -O2 -DQT3_SUPPORT -I/usr/local/Trolltech/Qt-4.1.2//mkspecs/default -I/usr/local/Trolltech/Qt-4.1.2//include/Qt3Support -I/usr/local/Trolltech/Qt-4.1.2//include/QtCore -I/usr/local/Trolltech/Qt-4.1.2//include/QtDesigner -I/usr/local/Trolltech/Qt-4.1.2//include/QtGui -I/usr/local/Trolltech/Qt-4.1.2//include/QtNetwork -I/usr/local/Trolltech/Qt-4.1.2//include/QtOpenGL -I/usr/local/Trolltech/Qt-4.1.2//include/QtSql -I/usr/local/Trolltech/Qt-4.1.2//include/QtXml -I/usr/local/Trolltech/Qt-4.1.2//include -I/usr/local/Trolltech/Qt-4.1.2//include/QtSvg -I/usr/local/Trolltech/Qt-4.1.2//include/QtTest -I/usr/local/Trolltech/Qt-4.1.2//include/QtDesigner -D_REENTRANT -DQT_THREAD_SUPPORT -DNO_DEBUG -I/usr/local/include -I/usr/include -I../../core -I../../ui -I../../gui -I../../raster -g -O2 -MT libqgis_plugin_va_la-va.lo -MD -MP -MF .deps/libqgis_plugin_va_la-va.Tpo -c va.cpp -fPIC -DPIC -o .libs/libqgis_plugin_va_la-va.o
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qmenubar.h:29: error: expected initializer before 'QtGuiModule'
    va.cpp: In member function 'virtual void vA1::initGui()':
    va.cpp:98: error: no matching function for call to 'QAction::QAction(QIcon, const char [4], vA1* const)'
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:173: note: candidates are: QAction::QAction(const QAction&)
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:73: note: QAction::QAction(const QIcon&, const QString&, const QKeySequence&, QObject*, const char*)
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:70: note: QAction::QAction(const QString&, const QKeySequence&, QObject*, const char*)
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:68: note: QAction::QAction(QObject*, const char*)
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:65: note: QAction::QAction(const QIcon&, const QString&, QObject*)
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:64: note: QAction::QAction(const QString&, QObject*)
    /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:63: note: QAction::QAction(QObject*)
    This code is part of a os project so i will not be in a position to post all code. But what i have figured out is it has got something to do with inclusion of some header files.

    Similar code is working fine but i am caught here.

    regards
    quickNitin
    Last edited by jacek; 30th August 2006 at 11:37. Reason: changed [ code ] to [ quote ] to allow wrapping

  2. #2
    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: strange error in compilation

    What does your project file look like?

  3. #3
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: strange error in compilation

    there is no pro file in my code.
    As i told earlier this code is part of a open souce gis qgis.There is a perl sript which make changes in major configuration files so i am not worried about them. And it was working fine for earlier work.

    Only this time it has stuck. I am not aware about need of project file.
    Also before that it was giving me problem with following code
    Qt Code:
    1. #
    2. nclude <qgisapp.h>
    3. #
    4. #include <qgsmaptool.h>
    5. #
    6. #include <qgsmapcanvas.h>
    7. #
    8. #include<qgspoint.h>
    9. #
    10. #include "../qgisplugin.h"
    11. #
    12. //#include<QToolBar> [COLOR="Red"]no inclusion of QToolBar headers[/COLOR]
    13. #
    14. //#include "vARubberBand.h"
    15. #
    16.  
    17. #
    18. //forward declarations
    19. #
    20.  
    21. #
    22. class QToolBar; [COLOR="Red"]FORWARD DECLARATION OF CLASS
    23. #[/COLOR]
    24. class vARubberBand;
    25. #
    26. /**
    27. #
    28. * \class Plugin
    29. #
    30. * \brief [name] plugin for QGIS
    31. #
    32. * [description]
    33. #
    34. */
    35. #
    36. class vA1:public QgsMapTool , public QgisPlugin
    37. #
    38. {
    39. #
    40. Q_OBJECT;
    41. #
    42. public:
    43. #
    44. vA1(QgisApp * theApplication, QgisIface * theInterface);
    45. #
    46. //! Destructor
    47. #
    48. virtual ~vA1();
    49. #
    50.  
    51. #
    52. //! inherited from QgsMapTool
    To copy to clipboard, switch view to plain text mode 

    It was reporting about some multiple declarations

    regards
    quickNitin

  4. #4
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: strange error in compilation

    Quote Originally Posted by quickNitin
    there is no pro file in my code.
    That's not good


    This line in qmenubar.h:
    Qt Code:
    1. usr/local/Trolltech/Qt-4.1.2//include/QtGui/qmenubar.h:29: error: expected initializer before 'QtGuiModule'
    To copy to clipboard, switch view to plain text mode 
    is calling macro (it's in qglobal.h):
    Qt Code:
    1. QT_MODULE(Gui)
    To copy to clipboard, switch view to plain text mode 
    which translates to:
    Qt Code:
    1. typedef QtValidLicenseForGuiModule QtGuiModule
    To copy to clipboard, switch view to plain text mode 

    But QtValidLicenseForGuiModule is defined only if QT_LICENSED_MODULE(Gui) macro is called. And this macro is called only if expression:
    Qt Code:
    1. QT_EDITION & QT_MODULE_GUI
    To copy to clipboard, switch view to plain text mode 
    evaluates to true. It evaluates to true only if QT_EDITION equals QT_EDITION_DESKTOPLIGHT or QT_EDITION_OPENSOURCE or QT_EDITION_DESKTOP. And QT_EDITION will be set to QT_EDITION_DESKTOP if you ie. build your project in a standard way:
    Qt Code:
    1. qmake -project
    2. qmake
    3. make
    To copy to clipboard, switch view to plain text mode 
    The Wheel weaves as the Wheel wills.

  5. #5
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default project file by ' qmake -pro'

    well i accept my arrogance of this aspect and insufficient knowledge of Qt. I will work on it.
    project file generated is as
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (1.07a) Wed Aug 30 15:08:08 2006
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. INCLUDEPATH += .
    7.  
    8. # Input
    9. HEADERS += ui_vaguibase.h \
    10. va.h \
    11. vagui.h \
    12. vaguibase.ui.h \
    13. vaRubberBand.h \
    14. vARubberBand.h \
    15. vATool.h
    16. INTERFACES += vaguibase.ui
    17. SOURCES += va.cpp va.moc.cpp va.qrc.cpp vagui.cpp vagui.moc.cpp vARubberBand.cpp
    To copy to clipboard, switch view to plain text mode 


    but it is still giving same output.
    Last edited by quickNitin; 30th August 2006 at 10:47. Reason: addition of result

  6. #6
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: project file by ' qmake -pro'

    Quote Originally Posted by quickNitin
    but it is still giving same output.
    Really? Is "qmenubar.h:29: error: expected initializer before 'QtGuiModule'" still there? Well, in that case I have no more ideas what the solution could be.

    As far as the second error is concerned:
    Qt Code:
    1. va.cpp: In member function 'virtual void vA1::initGui()':
    2. va.cpp:98: error: no matching function for call to 'QAction::QAction(QIcon, const char [4], vA1* const)'
    3. /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:173: note: candidates are: QAction::QAction(const QAction&)
    4. ...
    To copy to clipboard, switch view to plain text mode 
    It seems that in line 98 of va.cpp you are calling QAction constructor, but with wrong parameters. There is no QAction(QIcon, const char [4], vA1* const) constructor (at least according to compiler ) and it gives you a list of similar ones, which exist.
    The Wheel weaves as the Wheel wills.

  7. #7
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: strange error in compilation

    about QAction constructor error i had checked arguments do match and constructor also exists but it is giving me this error.
    Here is snap of that code
    Qt Code:
    1. void vA1::initGui()
    2. {
    3.  
    4. // Create the action for tool
    5. mQActionPointer = new QAction(QIcon(":/va/va.png"),"vA1", this);
    6. // Set the what's this text
    To copy to clipboard, switch view to plain text mode 
    At http://doc.trolltech.com/4.1/qaction.html i found this
    Qt Code:
    1. Public Functions
    2.  
    3. QAction ( QObject * parent )
    4.  
    5. QAction ( const QString & text, QObject * parent )
    6.  
    7. [COLOR="Blue"]QAction ( const QIcon & icon, const QString & text, QObject * parent )
    8. [/COLOR]
    9. ~QAction ()
    To copy to clipboard, switch view to plain text mode 


    About my other issue i request experienced users to guide me in this.
    Last edited by quickNitin; 30th August 2006 at 11:15. Reason: addition ot post

  8. #8
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QObject was not included

    for isssue
    Qt Code:
    1. va.cpp: In member function 'virtual void vA1::initGui()':
    2.  
    3. va.cpp:98: error: no matching function for call to 'QAction::QAction(QIcon, const char [4], vA1* const)'
    4.  
    5. /usr/local/Trolltech/Qt-4.1.2//include/QtGui/qaction.h:173: note: candidates are: QAction::QAction(const QAction&)
    6.  
    7. ...
    To copy to clipboard, switch view to plain text mode 
    i found that i hadn't included QObject class which i did so up mentioned error went away.

    About second issue of
    Qt Code:
    1. usr/local/Trolltech/Qt-4.1.2//include/QtGui/qmenubar.h:29: error: expected initializer before 'QtGuiModule'
    To copy to clipboard, switch view to plain text mode 

    i changed my header file as
    Qt Code:
    1. #ifndef vA_H
    2. #define vA_H
    3.  
    4. //QT4 includes
    5. #include <QObject>
    6.  
    7. //QGIS includes
    8. #include <qgisapp.h>
    9. #include <qgsmaptool.h>
    10. #include <qgsmapcanvas.h>
    11. #include<qgspoint.h>
    12. #include "../qgisplugin.h"
    13.  
    14. #include "vARubberBand.h"
    15. ;
    16. //forward declarations
    17.  
    18. class QToolBar;// LINE NO 54
    19.  
    20. /**
    21. * \class Plugin
    22. * \brief [name] plugin for QGIS
    23. * [description]
    24. */
    25. class vA1:public QObject, public QgsMapTool , public QgisPlugin
    26. {
    27. Q_OBJECT;
    28. public:
    To copy to clipboard, switch view to plain text mode 

    i think you will be noticing the semicolon after line
    Qt Code:
    1. #include "vARubberBand.h"
    To copy to clipboard, switch view to plain text mode 
    , this is what i did a sort of hit and trial to compile it. It did. If i didn't put this semicolon it give the message
    Qt Code:
    1. va.cpp line 54: multiple types in one declaration
    To copy to clipboard, switch view to plain text mode 
    i donot have reasoning for such behaviour. Kindly anyone put some light on this issue. All comments, suggestion and other solutions are welcome

    reagrds
    quickNitin

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject was not included

    Quote Originally Posted by quickNitin
    va.cpp line 54: multiple types in one declaration

    i donot have reasoning for such behaviour.
    Just add the missing semicolon after your class definition.

  10. The following user says thank you to jacek for this useful post:

    quickNitin (30th August 2006)

  11. #10
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: strange error in compilation

    thanks jacek!. I couldn't even imagine that this isssue was there.

Similar Threads

  1. very strange behaviour
    By regix in forum Qt Programming
    Replies: 23
    Last Post: 20th July 2006, 17:38
  2. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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.