Results 1 to 3 of 3

Thread: linking problem

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default linking problem

    Hi,

    I have the following case:
    Class MTelemetry is defined in an H file, at the moment its an empty class, implementing the defalut constructor and destructor in the H file it self, so there is no implementation file for it.
    I subclass it to class MServCon.
    Compiling goes well, but the linker complains:
    obj/mservcon.o: In function `MServCon::MServCon(QObject*)':
    mservcon.cpp.text+0x14): undefined reference to `vtable for MTelemetry'
    MServCon includes mtelemetry.h.

    I tried adding a forward declaration to MServCon, didn't help.
    What I might be missing?
    Here is the link line:
    g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.1.4/lib -o TMServCon obj/main.o obj/mservcon.o obj/moc_mservcon.o -L/usr/local/Trolltech/Qt-4.1.4/lib -lQtNetwo
    Thanks.

    Ofcourse one second oafter I posted I realized the problem - MTelemetry didn't get moc'ed...
    Last edited by high_flyer; 4th August 2006 at 23:09.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: linking problem

    So did you solve that problem? You should be able to do that by adding an #include "filename.moc" statement to the header file. Qmake should then force moc to process your file. At least it works when you put that statement into an implementation (.cpp) module where the class header is, but maybe it works this way round too.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: linking problem

    Yes I did, thanks.
    The problem with adding #include "mocfile" (which I tried at first) is that it has to be included in the makefile ofcourse, but it got to be a problem because I am working with KDevelop, and it automatically generates makefiles, so changing them manually is only good till the next qmake.
    I was looking (at first) for a way to have some classes just included as header files, so I wont need to have copies in the subprojects.
    I ended up creating a lib with my abstract classes as a subproject (which then gets moc'ed as well) and it solved all my problems.
    (I hope this was clear enough)

Similar Threads

  1. Permission denied error during linking
    By bashamehboob in forum Newbie
    Replies: 2
    Last Post: 15th April 2006, 13:02
  2. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  3. Replies: 16
    Last Post: 7th March 2006, 15:57
  4. Replies: 4
    Last Post: 20th February 2006, 09:11
  5. Runtime dynamic linking + Qt4 problem
    By _Ramirez_ in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2006, 14: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
  •  
Qt is a trademark of The Qt Company.