Results 1 to 3 of 3

Thread: specifying object code (/additional libraries) to be linked -- where?

  1. #1
    Join Date
    Apr 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question specifying object code (/additional libraries) to be linked -- where?

    Hello,

    I get "undefined reference to ..." linker errors.

    My definitions reside in a cpp file which do get compiled to object code.

    If I put the definitions inside the header file, the link process is without errors.

    Thus I guess that the link process inside QtCreator forgets to link the object code it created from my cpp files.

    Where do I specify the files to be linked?

    Or is this a different problem?

    Please help!

    Thanks

    Lars

  2. #2
    Join Date
    Apr 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: specifying object code (/additional libraries) to be linked -- where?

    btw. here's the implementation:
    Qt Code:
    1. #include "Y.h"
    2.  
    3. template<class X> Y<X>::~Y()
    4. {
    5. delete Something;
    6. }
    To copy to clipboard, switch view to plain text mode 
    It's defined in Y.cpp.

    If I put this code inside the header file Y.h, there are no problems. If I leave the code here, I get
    Qt Code:
    1. release/Z.o:Z.cpp::-1: error: undefined reference to `Y<_mytype>::~Y()'
    To copy to clipboard, switch view to plain text mode 
    . Z.cpp includes Y.h.

  3. #3
    Join Date
    Apr 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: specifying object code (/additional libraries) to be linked -- where?

    see http://www.linuxforums.org/forum/lin...ce-errors.html.

    Template classes must be declared and defined in one file, ie. putting implementation in cpp doesn't work as the specific type to be used in the template is unknown on compile time thus the compiler can't generate code for the implementation (having the implementation included in the file which is included in the code where the template is instantiated makes the type in the template known.)

Similar Threads

  1. Replies: 1
    Last Post: 27th February 2010, 11:33
  2. Replies: 2
    Last Post: 3rd December 2009, 07:04
  3. Additional libs for linker
    By megabyte-ceercop in forum Qt Tools
    Replies: 3
    Last Post: 26th March 2009, 07:16
  4. XCode and additional files
    By themolecule in forum Qt Programming
    Replies: 0
    Last Post: 6th May 2008, 07:57
  5. QDate without additional character
    By raphaelf in forum Qt Programming
    Replies: 2
    Last Post: 17th February 2006, 22:16

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.