Results 1 to 6 of 6

Thread: undefined reference to vtable

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default undefined reference to vtable

    Qt Code:
    1. /*
    2.  * Created On : 2006/02/10
    3.  * Revision : 1.0.0
    4.  * Purpose : Represents Payscale
    5.  * Note : Files without revision and date of creation are to be ignored
    6.  */
    7.  
    8. #ifndef RANGE_H
    9. #define RANGE_H
    10.  
    11. #include "List.h"
    12.  
    13.  
    14. class RangeDetailItem : public ListItem {
    15. public:
    16. RangeDetailItem() ;
    17.  
    18. RangeDetailItem( Indicator );
    19. ~RangeDetailItem() {}
    20.  
    21. int minRange() const;
    22. void setMinRange( int iMinRange );
    23.  
    24. int maxRange() const;
    25. void setMaxRange( int iMaxRange );
    26. /*
    27.   int annualIncrement() const;
    28.   void setAnnualIncrement( int iAnnualIncrement );
    29. */
    30. bool load( Q_LLONG lFkeyId );
    31. bool insert();
    32. bool update();
    33. bool remove();
    34.  
    35. private:
    36. //int m_iAnnualIncrement;
    37. int m_iMaxRange;
    38. int m_iMinRange;
    39. };
    40.  
    41.  
    42. class RangeDetail : public List<RangeDetailItem> {
    43. public:
    44. RangeDetail():List<RangeDetailItem>(
    45. "fki_range_id",
    46. "pki_range_detail_id",
    47. "tbl_hrms_range_detail"){}
    48. ~RangeDetail() {};
    49. };
    50.  
    51.  
    52. class Range : public DataComponent {
    53. public:
    54. Range();
    55.  
    56. QString code() const;
    57. void setCode( const QString& strCode );
    58.  
    59. QString remark() const;
    60. void setRemark( const QString& strRemark );
    61.  
    62.  
    63. RangeDetail detail() const ;
    64. void setDetail( const RangeDetail& rangeDetail );
    65.  
    66. bool load( Q_LLONG lPkeyId );
    67.  
    68. bool insert();
    69. bool update();
    70. bool remove();
    71.  
    72. private:
    73. bool validateInsert();
    74. bool validateUpdate();
    75.  
    76. private:
    77. QString m_strCode;
    78. QString m_strRemark;
    79. RangeDetail m_rdDetail;
    80. };
    81.  
    82.  
    83.  
    84. //__RangeDetailItem_________________________________________________________
    85.  
    86. inline RangeDetailItem::RangeDetailItem()
    87. :ListItem( ListItem::Insert,
    88. "fki_range_id",
    89. "pki_range_detail_id",
    90. "tbl_hrms_range_detail") {}
    91.  
    92. inline RangeDetailItem::RangeDetailItem( Indicator ind )
    93. :ListItem( ind, "fki_range_id",
    94. "pki_range_detail_id", "tbl_hrms_range_detail" ) {}
    95.  
    96. inline int RangeDetailItem::minRange() const {
    97. return m_iMinRange;
    98. }
    99. inline void RangeDetailItem::setMinRange( int iMinRange ) {
    100. m_iMinRange = iMinRange;
    101. }
    102.  
    103.  
    104. inline int RangeDetailItem::maxRange() const {
    105. return m_iMaxRange;
    106. }
    107. inline void RangeDetailItem::setMaxRange( int iMaxRange ) {
    108. m_iMaxRange = iMaxRange;
    109. }
    110.  
    111. /*
    112. inline int RangeDetailItem::annualIncrement() const {
    113.   return m_iAnnualIncrement;
    114. }
    115. inline void PayscaleDetailItem::setAnnualIncrement( int iAnnualIncrement ) {
    116.   m_iAnnualIncrement = iAnnualIncrement;
    117. }
    118.  
    119. */
    120. //__Payscale_________________________________________________________
    121.  
    122. inline Range::Range():DataComponent(
    123. "uvc_range_code","pki_range_id", "tbl_hrms_range") {}
    124.  
    125. inline QString Range::code() const {
    126. return m_strCode;
    127. }
    128. inline void Range::setCode( const QString& strCode ) {
    129. m_strCode = strCode.stripWhiteSpace();
    130. }
    131.  
    132. inline QString Range::remark() const {
    133. return m_strRemark;
    134. }
    135. inline void Range::setRemark( const QString& strRemark ) {
    136. m_strRemark = strRemark.stripWhiteSpace();
    137. }
    138.  
    139. inline RangeDetail Range::detail() const {
    140. return m_rdDetail;
    141. }
    142.  
    143. inline void Range::setDetail( const RangeDetail& rangeDetail ) {
    144. m_rdDetail = rangeDetail;
    145. }
    146.  
    147.  
    148.  
    149.  
    150. #endif // RANGE_H
    To copy to clipboard, switch view to plain text mode 

    in Line No 86

  2. #2
    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: undefined reference to vtable

    Could you post the exact error message?

  3. #3
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to vtable

    Define at least one function for RangeDetailItem (the destructor will do) in the cpp file. This often happens when you try to fully inline a class that has virtual inheritance - at least one method of the class must be outlined, so the compiler can figure out where to generate the vtable information.

    If this doesn't work - well I guess the problem could be somewhere else...
    Save yourself some pain. Learn C++ before learning Qt.

  4. #4
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to vtable

    This usually happens when you've run qmake without having the Q_OBJECT macro. If you don't have that qmake won't add the right stuff to the make. So, once you've added it make needs to run again or when you link to the moc object it won't exist and will give you a vtable error. Run make clean, then qmake, the make again and see if that works

  5. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to vtable

    Quote Originally Posted by jrideout
    This usually happens when you've run qmake without having the Q_OBJECT macro. If you don't have that qmake won't add the right stuff to the make. So, once you've added it make needs to run again or when you link to the moc object it won't exist and will give you a vtable error. Run make clean, then qmake, the make again and see if that works
    I don't think that any of the classes that he has declared there need the Q_OBJECT macro, do they?
    Save yourself some pain. Learn C++ before learning Qt.

  6. #6
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to vtable

    Actually, your right, I didn't look at the code closely. Perhaps, my post might give him some ideas though, whatever the reason, a vtable error is a linker matchup problem.

Similar Threads

  1. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 20:15
  2. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 20:36
  3. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 09:52
  4. undefined reference to fftw libraries
    By kmyadam in forum General Programming
    Replies: 2
    Last Post: 9th March 2006, 02:01
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 9th March 2006, 00:11

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.