-1

I am using static linking to build my libraries for a qt app. I am using boost in one of my C++ internal libraries. I am using .pro files for my internal library where I have defined boost libs location & boost headers files location as my library depends on boost. All of this builds fine & great up till now.

My qt app is linking to my internal static library which in turn uses boost. The problem is that when I try to include a header from my internal library which uses boost, this fails to build unless 'I include boost in my app's .pro file'. Including boost dependency in app's pro file makes the build work all fine but I don't want to do this as the app should worry about a library's dependencies whether boost or whatever it is. Is there some way to avoid my app to worry about boost when it is not using it directly ?

I read the following link which looks like a similar problem but the answer doesn't work for me How to link Boost in a dependant static library

Any expertise shared is appreciated. Thanks in advance.

Community
  • 1
  • 1
Rubin
  • 201
  • 1
  • 3
  • 8
  • 1
    You application uses boost. You are surprised you need to link boost. Why? – Jesper Juhl Jun 05 '16 at 13:24
  • No. MyStaticLibrary1 uses boost & app uses MyStaticLibrary1. This causes app to include boost even if it is not directly using it. Thats the situation. I am trying to get way to avoid app dependency on boost. – Rubin Jun 05 '16 at 15:17
  • If your app uses a library that uses boost, then your app uses boost. Simple as that. – Jesper Juhl Jun 05 '16 at 15:18

1 Answers1

2

A static library is really nothing more than a collection (an archive) of object files, when you link with a static library it's like linking with the separate object files.

That's why if you use an external third-part library in a static library, you need to link with that external third-part library whenever you want your own static library.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Aah. I feared so. Thanks for the clarification. May be I can avoid this by not having the boost inclusion in exported headers of the library ? – Rubin Jun 05 '16 at 15:14