如何将多个 C/C++ 库合二为一? [英] How to combine several C/C++ libraries into one?

查看:29
本文介绍了如何将多个 C/C++ 库合二为一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我厌倦了在我的项目中添加十个链接库,或者需要其中八个使用我自己的.我想采用现有的库,如 libpng.a、libz.a、libjpeg.a,并将它们组合成一个单一的 .a 库.那可能吗?结合 .lib 库怎么样?

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?

推荐答案

在类 Unix 系统上,ld 和 ar 实用程序可以做到这一点.查看 http://en.wikipedia.org/wiki/Ar_(Unix)或者在任何 linux 机器上或通过谷歌查找手册页,例如unix man ar".

On Unix like systems, the ld and ar utilities can do this. Check out http://en.wikipedia.org/wiki/Ar_(Unix) or lookup the man pages on any linux box or through google, e.g 'unix man ar'.

请注意,最好链接到共享(动态)库.这会增加对可执行文件的依赖,但会显着减小其大小,尤其是在您编写图形应用程序时.

Please note that you might be better off linking to a shared (dynamic) library. This would add a dependency to your executable but will dramatically reduce its size, especially if you're writing a graphic application.

这篇关于如何将多个 C/C++ 库合二为一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆