Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine several C/C++ libraries into one?

Tags:

c++

c

archive

I'm tired of adding ten link libraries into my project, or requiring eight of them to use my own. I'd like to take existing libraries like libpng.a, libz.a, libjpeg.a, and combine them into one single .a library. Is that possible? How about combining .lib libraries?

like image 214
GhassanPL Avatar asked Aug 16 '08 13:08

GhassanPL


1 Answers

You could extract the object files from each library with

ar x <library name> 

and then merge them all into a new library with

ar cs <new library name> <list each extracted object file> 
like image 164
Judge Maygarden Avatar answered Oct 14 '22 04:10

Judge Maygarden