DO we Need to include headers in my program if we are using static Library in Nested scenario?
-
wrote on 19 Sept 2013, 13:52 last edited by
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?) -
wrote on 19 Sept 2013, 14:04 last edited by
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
-
wrote on 19 Sept 2013, 14:37 last edited by
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]
-
wrote on 19 Sept 2013, 14:50 last edited by
static library means that the library calls will get resolved at compile time and copied into your application/library.
- yes
- 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/4