Nitish Upreti
Nitish Upreti

Reputation: 6550

Using a subset of functionality from a Library in C++

I am using SNAP library in one of my project. I have a #include"Snap.h" which gives me the entire library's functionality. However, I am just using the k-core algorithm and the underlying graph DS.

There is a lot of extra DS+Algorithms provided by the library as discussed here: http://snap.stanford.edu/snap/description.html

If I compile the entire project and link my code with this library, it seems I will end up with a lot of extra stuff? Also I need to have the entire project directory setup for including appropriate headers.

The situation seems quite generic to C++, is there a quick and easy way to compile a subset of this library with only the features I need ?

Upvotes: 0

Views: 100

Answers (2)

Nitish Upreti
Nitish Upreti

Reputation: 6550

I solved my problem by using Boost and using the bcp utility to extract the relevant pieces of the library.

Upvotes: 0

ezaquarii
ezaquarii

Reputation: 1916

  1. if the library is dynamically linked and distributed as precompiled binary, you must live with that
  2. if the library is statically linked you can use dead code elimination (if your compiler support it)
  3. if you have sources, you can trim the library by removing unused code - ie. make your own library based on selected code only

Upvotes: 1

Related Questions