Results 1 to 4 of 4

Thread: how to create application with 2 library

  1. #1
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default how to create application with 2 library

    hi.

    i create application where i use 2 library.
    library1 is used in library2 and library2 is used in application.

    library1 and library2 is compiled OK, but when i try compile App, i have error:

    No such file or directory xxx.h, but this xxx.h is in library1

    how can i load this library in app?

    .pro file of library1
    Qt Code:
    1. TARGET = library1
    2. TEMPLATE = lib
    3. CONFIG += staticlib
    4. QT += network
    5. DEFINES += QLIBRARY1_LIBRARY
    6. MOC_DIR = tmp
    7. OBJECTS_DIR = obj
    8. DESTDIR += ../libLibrary1/bin
    To copy to clipboard, switch view to plain text mode 

    .pro file of library2
    Qt Code:
    1. QT += core gui sql network
    2. TARGET = library2
    3. TEMPLATE = lib
    4. CONFIG += staticlib
    5. DEFINES += QLIBRARY2_LIBRARY
    6. DESTDIR = ../libLibrary2
    7. MOC_DIR = tmp
    8. OBJECTS_DIR = obj
    9. INCLUDEPATH += ../libLibrary1
    10. QMAKE_LIBDIR += ../libLibrary1
    11. LIBS += -L/bin -llibrary1
    To copy to clipboard, switch view to plain text mode 

    .pro file of app
    Qt Code:
    1. QT += core gui
    2. TARGET = QApp
    3. TEMPLATE = app
    4. INCLUDEPATH += ../libLibrary2
    5. QMAKE_LIBDIR += ../libLibrary2
    6. LIBS += -llibrary2
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how to create application with 2 library

    No such file or directory xxx.h, but this xxx.h is in library1
    May be you are including xxx.h file from a header file of library2 which is being included from app.

    Options:
    1. Add library1 include path in app project file
    2. Change the library2 header files (which are needed by app) so that they don't depen of xxx.h file
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    stevocz (27th August 2013)

  4. #3
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: how to create application with 2 library

    all .h files from library1 have same error.

    app is for now only mainwindow for test. In library2 is widget and this widget want i show in app

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to create application with 2 library

    Quote Originally Posted by stevocz View Post
    all .h files from library1 have same error.
    So the same solution will fix all of them.
    The compiler needs to know how to find all the include files the application needs in order to compile it. If the application needs the definition of a class in lib A to compile then it will need ( directly or indirectly) access to a header that defines it. You can adjust the places the compiler looks with INCLUDEPATH.

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

    stevocz (27th August 2013)

Similar Threads

  1. Replies: 3
    Last Post: 1st February 2013, 21:41
  2. create and use shared library in qt
    By bibhukalyana in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2011, 08:48
  3. Replies: 2
    Last Post: 19th February 2011, 12:26
  4. Replies: 4
    Last Post: 18th December 2009, 19:55
  5. How create a dll/ library with Qt
    By ccosta in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 23:02

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.