Results 1 to 12 of 12

Thread: Including a self-made library into another project

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: Including a self-made library into another project

    Also, your application project file doesn't look right. 'LIBS += -L../../bin/libMyLibrary.so' just adds the directory to the linker search path; you need to add '-lMyLibrary' to it. The 'undefined reference' error indicates that the linker can't find your library.

    But note that whatever else may be in your library, templated classes will not appear. Templates aren't code, and aren't compiled into libraries; templates are...templates that tell the compiler how to generate code when an actual instantiation of a template class occurs, so unless your library creates an instance of a template class there is nothing in it that's template related. The only place the template is defined is in the header, which is roped in at compile time.

    This is all somewhat oversimplified.
    Last edited by SixDegrees; 27th May 2011 at 08:56.

  2. #2
    Join Date
    Mar 2011
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Including a self-made library into another project

    Thanks. Just to know, If I can't export a template with a library, how can works Qt container like, for example, QVector? Because in that case I simply include the qvector header and I can use the template. How can I do something similiar?

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: Including a self-made library into another project

    You include all of your implementation in your header file so there's nothing to compile and nothing to build into a link library.

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Including a self-made library into another project

    If I can't export a template with a library
    You can deploy a header containing the template definition with other headers in library, I don't see a problem here.
    Or do you mean you want to have a template code in .so file somehow ? In that case I'd suggest you read more about templates.
    If this library is nothing more than a template, then you don't need any .so files, no linking to the library is required, because there is nothing to link to. All needed code will be generated in case of template instantiation.
    So in fact using this library means including the header and creating an instance of template class (or method).

  5. #5
    Join Date
    Mar 2011
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Including a self-made library into another project

    Thanks, I've also read something about that. It's the first time that I use it for a serious project, so before I'd never noticed template differences from normal classes because I've used them always in the same project...

    I have a lot to learn :-)

    Thanks to anyone.

Similar Threads

  1. Including a static library
    By jepessen in forum Newbie
    Replies: 3
    Last Post: 6th May 2011, 10:35
  2. linux project made in windows
    By alimooghashang in forum Qt Programming
    Replies: 2
    Last Post: 26th August 2010, 07:46
  3. Including GMP in Qt-Project
    By tillorgias in forum Newbie
    Replies: 3
    Last Post: 3rd July 2010, 21:55
  4. Problem including library (dllimport)
    By cae in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2010, 07:53
  5. Replies: 4
    Last Post: 18th December 2009, 19:55

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
  •  
Qt is a trademark of The Qt Company.