Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DO we Need to include headers in my program if we are using static Library in Nested scenario?
Forum Update on Monday, May 27th 2025

DO we Need to include headers in my program if we are using static Library in Nested scenario?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blue_sky
    wrote on 19 Sept 2013, 13:52 last edited by
    #1

    If I am using members of a class which a Static lib,Then I must add header file of that class in my .cpp.
    But, If that class is using some other libs, then should I include those other libs(class) header in my cpp file.

    ex= my program

    need a class which in X.lib.
    I am using only X class object in
    my cpp.So I should include X class header
    in my file.
    But if X class in X.lib is using another lib Y.lib internally,
    then should I include Y class definition in my CPP?
    (I know Y.lib must be included in my project, but should Y.h should be included?)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clogwog
      wrote on 19 Sept 2013, 14:04 last edited by
      #2

      not particularly a Qt question, but i'll give it a try:

      no, if you only use the public interface of lib X then X.h would give you all that is needed during compile time.

      that lib X uses lib Y for it's implementation is none of your concern. only when you want to access lib Y's data structures and/or functions would you possibly need to include Y.h

      If lib X exposes whole or parts of the data structures/functions inside of lib Y then x.h would already #include y.h

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blue_sky
        wrote on 19 Sept 2013, 14:37 last edited by
        #3

        Thank you for your answer.
        1// But Is it possible to make a static lib which need another static lib?
        2//If above is possible,then in which scenario all codes of lib2 are not copied into lib1, so that I need both of them when linking lib1 to my program.
        -======================
        [quote author="clogwog" date="1379599443"]not particularly a Qt
        question, but i'll give it a try:

        no, if you only use the public interface of lib X then X.h would give you all that is needed during compile time.

        that lib X uses lib Y for it's implementation is none of your concern. only when you want to access lib Y's data structures and/or functions would you possibly need to include Y.h

        If lib X exposes whole or parts of the data structures/functions inside of lib Y then x.h would already #include y.h[/quote]

        1 Reply Last reply
        0
        • C Offline
          C Offline
          clogwog
          wrote on 19 Sept 2013, 14:50 last edited by
          #4

          static library means that the library calls will get resolved at compile time and copied into your application/library.

          1. yes
          2. only functions that are resolved/needed will get copied, so if lib Y only uses half of lib X, then lib Y will only have that half of lib X in it.
          1 Reply Last reply
          0

          1/4

          19 Sept 2013, 13:52

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved