Results 1 to 4 of 4

Thread: Vtable linker error

  1. #1
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Vtable linker error

    Hi,
    I've read the previous thread with vtable problem. I'm having a similar problem.
    Fedora Core 6, QT 4.3, Fedora Eclipse with GCC.
    I have QT 3.3 from the Fedora System install still in /usr/include/qt-3.3, but have pointed everything in my Eclipse project towards QT 4 includes and libs (/usr/include/qt4). I also have the env variables QTDIR, QTLIB, and QTINC pointed towards Qt4, and have Qt4 at the head of the PATH.

    In addition I can compile the QT tutorials against QT4 using qmake, say on t1.pro, then make.

    But when I try to compile in Fedora Eclipse using GCC in a CPP project I get a linker error:
    undefined reference to `vtable for Window' etc.

    The .cpp files compile, but the linker gives up. Below is what I have for my -L and -l commands. I've also tried using qmake to generate a makefile, and then model my IDE proj settings off those, but seems like I'm still missing a lib or have something incorrect.

    Thanks for any help or info.

    make -k all
    Building target: QTwidget1
    Invoking: GCC C++ Linker
    g++ -L/usr -L/usr/bin -L/usr/lib -L/usr/lib/qt4 -L/usr/lib/qt4/lib -L/usr/lib/qt4/bin -o"QTwidget1" ./coinwidget.o ./main.o ./model.o ./window.o -lCoin -lSoQt -lsimage -lGL -lGLU -lQtOpenGL -lQtGui -lQtCore -lQt3Support
    ./coinwidget.o: In function `~CoinWidget':
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: undefined reference to `vtable for CoinWidget'
    ./coinwidget.o:/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../coinwidget.cpp:22: more undefined references to `vtable for CoinWidget' follow
    ./main.o: In function `~Window':
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.h:15: undefined reference to `vtable for Window'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.h:15: undefined reference to `vtable for Window'
    ./window.o: In function `Window':
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: undefined reference to `vtable for Window'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: undefined reference to `vtable for Window'
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: undefined reference to `vtable for Window'
    ./window.o:/home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.cpp:5: more undefined references to `vtable for Window' follow
    ./window.o: In function `Window::tr(char const*, char const*)':
    /home/JCH/workspaceSoGui_SoQt/QTwidget1_qt4/Debug/../window.h:16: undefined reference to `Window::staticMetaObject'
    collect2: ld returned 1 exit status
    make: *** [QTwidget1] Error 1
    make: Target `all' not remade because of errors.
    Build complete for project QTwidget1_qt4

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Vtable linker error

    Do you have any virtual functions in CoinWidget or in Windows which are not implemented in the subclasses? Perhaps a virtual destructor or some other virtual function you forgot to implement...
    This is usually the reason for this error.

    Also, what about the Q_OBJECT macro? Did you add it to all the classes which implement/use signals/slots?

    And where are the moc files? I am sure you must have at least one generated moc( for the window ). They should have been passed to gcc... Could you take a look and see if there are any moc files generated in you project?

    Is your Eclipse set to call moc at all?

    I could also be that Qt was compiled with another GCC version than you currently use. Is this the case?

    Regards
    Last edited by marcel; 21st July 2007 at 07:15.

  3. #3
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Vtable linker error

    Hi,
    In that case then, maybe Fedora Eclipse is not the best IDE for trying to do this since still seems like it might require pushing the .h files thru moc, then linking those with other .cpp files.

    I'll take a look at Kdevelop and see if that helps move things along.

    regards,

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Vtable linker error

    There is a tech preview for the Qt Eclipse Integration.
    I have heard it is stable.

    Maybe you can use this until they make the final release. Eclipse is an excellent IDE and I encourage you to use it.
    Here is the link:http://trolltech.com/company/newsroo...-24.8884335791.
    There is a version for linux too.

    Regards

Similar Threads

  1. Installation on Fedora Core 4
    By jcr in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2009, 01:34
  2. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  3. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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.