Results 1 to 2 of 2

Thread: Library dependency issue

  1. #1
    Join Date
    Mar 2011
    Qt products
    Unix/X11 Windows

    Default Library dependency issue

    I've a problem with an application that I'm developing.

    In this application, I've three projects:

    A - The application
    B - a library used by the application
    C - a library used by B

    in the B project, I declare the class in his header file (libB.h), like this:

    Qt Code:
    1. #include "libB_global.h"
    2. #include "libC.h"
    4. class METEOGRIDSHARED_EXPORT AtmosphericGrid
    5. {
    7. ... some code using library C
    9. }
    To copy to clipboard, switch view to plain text mode 

    To do this, in the .pro of the B project I add the path in which the class header of library C is defined, and I add the header of that class, so che .pro of the library B contains something like this:

    Qt Code:
    1. # Including project C
    2. INCLUDEPATH += ../../libC
    3. HEADERS += libC.h
    To copy to clipboard, switch view to plain text mode 

    Now, in the application A, I want to use library B. To do this, I add in the .pro file of A application, the following lines:

    Qt Code:
    1. # Using B Library
    3. LIBS += ../../bin/
    4. INCLUDEPATH += ../../B
    5. HEADERS += libB.h
    To copy to clipboard, switch view to plain text mode 

    But, if I do this, I've a compiler error:

    In file included from ../A/main.cpp:5:0:
    ../../libB/libB.h:6:29: fatal error: libC.h: missing file or directory
    (the message cannot be equal, because I've translated it from italian).

    In practice, it does not compile because in A I've a reference for the C header (included in the B header).
    In other words, to compile A, I need header B, that includes header C that I must define in A. If I don't define C path in A, it doesn't work But I don't want to do this, because I lost all advantages in using different projects.

    I'd like that A depends only from B, withouht taking in account all dependies of B, but it'a impossible if I use header files as I'a actually doing.
    How can I achieve this result?

    Thanks in advance for your replies.

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: Library dependency issue

    You need to move #include "libC.h" from "libB.h" to "libB.cpp" or equivalent. Use forward declarations in libB.h instead.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. Linux deployment issue, dependency not satisfiable.
    By skepticalgeek in forum General Programming
    Replies: 1
    Last Post: 29th November 2010, 13:23
  2. Library dependency in Qt 4.6
    By Tino in forum Installation and Deployment
    Replies: 1
    Last Post: 7th December 2009, 18:28
  3. Qmake fails to set shared library dependency
    By jkv in forum Qt Programming
    Replies: 5
    Last Post: 3rd September 2009, 13:44
  4. qmake: dependency of application on common shared library
    By PeterWurmsdobler in forum Qt Programming
    Replies: 5
    Last Post: 27th March 2009, 16:13
  5. Replies: 11
    Last Post: 18th May 2007, 10:38

Tags for this Thread


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.