shashashamti2008
shashashamti2008

Reputation: 2327

Is it possible to bundle multiple static libraries into a single static library[C++]?

I created a static library for my C++ code that depends on Boost, OpenSSL, CURL, and Threads in a CentOS 7 environment.

Is it possible to bundle libboost_system.a, libssl.a, libcrypto.a, libcurl.a, libpthread.a alongside my C++ library into a single library?

Upvotes: 2

Views: 1095

Answers (1)

Stephen Harris
Stephen Harris

Reputation: 371

.a files are just archives; you can use the ar command to manipulate them.

So you could extract all the objects (ar x) from each of the libraries and then create a new library (ar a) with all the individual files.

However this probably isn't a good idea because it means you have to keep rebuilding this each time one of the upstream libraries changes (eg due to a security issue being fixed).

It's normal for a program to have multiple library dependencies and inclusions.

Upvotes: 6

Related Questions