Results 1 to 3 of 3

Thread: Include internal library to project - Library dropdown list is empty

  1. #1
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Include internal library to project - Library dropdown list is empty

    I'm trying to add an internal library to my project using an example from here:
    Example of Adding Internal Libraries

    I have a minimal Qt Widget Application (created by the creator itself, which is running). Then I added an other project, as said in the example. In step 4 I can not select any project from the list (Add as subproject to project), because it is empty and disabled.

    Using the contextmenu of my Widget project, I select 'Add library', then 'Internal library'. In that dialog the dropdown list 'library' is empty, but enabled.

    I'm using Qt Creator 4.0.3, Based on Qt 5.7.0 (MSVC 2013, 32 bit), Jul 5 2016 01:09:09.

    What am I doing wrong?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Include internal library to project - Library dropdown list is empty

    The thing I would try is this:

    1) rename the .pro file you have to something like application.pro
    2) create a new .pro file with the original name with this content
    Qt Code:
    1. TEMPLATE = subdirs
    2. SUBDIRS = application.pro
    To copy to clipboard, switch view to plain text mode 

    You should still be able to built the application as before

    3) Create a library project as a subdirectory of your main project
    4) Add the library directory to SUBDIRS, e.g.
    Qt Code:
    1. SUBDIRS = mylibrary application.pro
    To copy to clipboard, switch view to plain text mode 

    Alternatively you create a new top level directory with a SUBDIRS .pro file and both the application project and library project as sibling subdirectories
    Qt Code:
    1. SUBDIRS = mylibray orginalprojectdir
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Include internal library to project - Library dropdown list is empty

    Thanks for your reply. It didn't work for me, but I've done a similar thing with the QtCreator.

    1. New Project:
    Console
    Name 'LibTest'
    Folder 'E:\Project\Qt', Kit 'Desktop Qt 5.7.0 MinGW 32bit'

    2. New Project
    C++ library
    static linking
    Name 'MyLib'
    Folder 'E:\Project\Qt\LibTest'
    Kit 'Desktop Qt 5.7.0 MinGW 32bit'
    Modules 'QtCore'

    3. Added Method (mylib.h)
    Qt Code:
    1. #ifndef MYLIB_H
    2. #define MYLIB_H
    3.  
    4. class MyLib {
    5. public:
    6. MyLib();
    7. int Test() { return 123; }
    8. };
    9.  
    10. #endif // MYLIB_H
    To copy to clipboard, switch view to plain text mode 

    4. Adding existing subfolder to project 'LibTest' via context menu & dialog added to 'LibTest.pro':
    Qt Code:
    1. SUBDIRS += \
    2. MyLib/MyLib.pro
    3.  
    4. HEADERS += \
    5. MyLib/mylib.h
    To copy to clipboard, switch view to plain text mode 

    5. Changed main function to test MyLib::Test() method call
    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QTextStream>
    3. #include "MyLib/mylib.h"
    4.  
    5. int main(int argc, char *argv[]) {
    6. QCoreApplication a(argc, argv);
    7.  
    8. MyLib instance;
    9. QTextStream stream(stdout);
    10.  
    11. stream << "MyLib::Test returned: " << instance.Test() << endl;
    12.  
    13. return 0;
    14. }
    To copy to clipboard, switch view to plain text mode 

    6. Running programm was successfull
    Output: MyLib::Test returned: 123


    So my problem is partially solved, but it seems, that adding an internal library via GUI is not working.


    Added after 1 37 minutes:


    Sorry, I found the problem: I've used the wrong project type!


    SUBDIRS - handling dependencies


    Now the dropdown lists are filled.
    Last edited by bilgenratte; 5th January 2017 at 13:54.

Similar Threads

  1. Debugging internal library
    By gavinmagnus in forum Qt Programming
    Replies: 2
    Last Post: 10th October 2016, 13:57
  2. is possible include linux library?
    By stevocz in forum Installation and Deployment
    Replies: 1
    Last Post: 11th March 2014, 09:48
  3. How to include id3lib library in Qt (Windows)
    By Divad in forum Qt Programming
    Replies: 6
    Last Post: 17th January 2014, 17:51
  4. How to include library using config+=mylibrary
    By marcvanriet in forum Qt Programming
    Replies: 8
    Last Post: 11th September 2011, 21:17
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.