Reputation: 47855
I'm writing a shared library that itself depends on boost
and pcl
libraries.
When generating .pc
file for my library should I add all these libraries also to the .pc
file as dependencies?
It's been a long time since I last time studied these things and I'm a bit confused how this worked again on Linux. When my test app links to my lib I have to add all these pcl
and boost
libs again to the build even though the lib already has been linked against these libs.
But when I look at the deps of libQtGui.so
, for example, it has tens of all kinds of libs it links to, but I don't need to make my app link to those libs...only -lQtGui
is enough.
I have just used CMake and link_libraries
to add boost
and pcl
libs.
Upvotes: 0
Views: 693
Reputation: 7119
When generating .pc file for my library should I add all these libraries also to the .pc file as dependencies?
It depends on API of your library:
#inclue <boost/...>
) (in other words you used PUBLIC
(or INTERFACE
) named keywords when link your library against boost/pcl in CMake+target_link_libraries
) -- then yes you need to add 'em;DT_NEEDED
entries for boost/pcl libs (most likely) or not (you can check it w/ ldd <your-lib>.so
). For the last case, you also need to add your dependencies to the *.pc
files.Also, in case of binary dependency from boost/pcl (dunno if the latter has any DSO or not) please make sure you specify exact location of the linked libs -- cuz a user may have multiple (co-existed) boost installations (potentially incompatible) or can do upgrade (later) to other (binary incompatible) version (and you can't really do smth w/ it)… It is important to be linked to the same (or at least binary compatible, which is kinda hard to guarantee for boost) library as you did…
I have just used CMake and
link_libraries
to add boost and pcl libs.
Please read smth about "Modern CMake" and stop using link_libraries
:-) -- use target_link_libraries
instead…
Upvotes: 1