Results 1 to 5 of 5

Thread: Best approach to keep a set of common functions

  1. #1
    Join Date
    Oct 2012
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Best approach to keep a set of common functions

    Hi all,

    I'd like to know the best approach for keeping one or more sources containing functions in a way I can reuse them easily in several projects. Or, in other words, I'd like to create a personal library of common functionalities (custom math functions, for example).
    And, as a newbie, how I follow that approach in Qt Creator (menu options etc.)?

    P.S.:
    if answer is ".lib's", I've tried to create .lib's at %CPPLIBS% directory but I failed in each step :-( ...
    how do I create .lib in Qt Creator?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Best approach to keep a set of common functions

    To create a library with Creator you do this: New project -> Other Project -> C++ Library and in the dialog that appears after you can configure if you create a shared library or a statically linked one (from what i understand this is what you want).

    //Another way that may fit your needs is to create a header only library.

  3. #3
    Join Date
    Oct 2012
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Best approach to keep a set of common functions

    ok, I'll try both of them.

    And how do I use each of them in the client project? I'm using #include but it doesn't work. The "Add library..." option always look for a .lib, which I can't find it anywhere :-(

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Best approach to keep a set of common functions

    To reuse a library in a project you use the qmake's: INCLUDEPATH and (if necessary) LIBS in the project file (.pro extension).

  5. #5
    Join Date
    Oct 2012
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Best approach to keep a set of common functions

    error message:

    undefined reference to <myfunction>

  6. The following user says thank you to czdcriacoes for this useful post:


Similar Threads

  1. Loading and managing common DLLS
    By navi1084 in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2010, 13:40
  2. Using a common datamodel across dialogs?
    By Frozenjim in forum Qt Programming
    Replies: 1
    Last Post: 14th October 2008, 00:14
  3. Common question about porting Qt3 to Qt4
    By zlatko in forum Qt Programming
    Replies: 4
    Last Post: 21st February 2007, 10:57
  4. Common icon repository
    By brcain in forum Newbie
    Replies: 2
    Last Post: 27th September 2006, 19:30
  5. Common slot on some widgets [Qt3]
    By Opilki_Inside in forum Newbie
    Replies: 4
    Last Post: 27th March 2006, 14:26

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.