提取大型图书馆的一小部分(FX提升) [英] Extracting small parts of large library (fx boost)

查看:166
本文介绍了提取大型图书馆的一小部分(FX提升)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个自动化的方式来提取大型C的一小部分++库。

I would like to know if there is an automated way to extract a small portion of a large C++ library.

比方说,我只需要提振::理性一些项目。但是整个升压1.42占用了279种MIB!

Let's say I only need boost::rational in some project. However entire boost 1.42 takes up 279 MiB!

要保留我的项目自足(FX一些学校工作),我希望能够包括升压::用我自己的源一起理性。 (这个想法是,我的老师不应该安装库的1000年提前,以编译)

To keep my project "self-contained" (fx for some school work), I would like to be able to include boost::rational along with my own source. (The idea being, that my teacher should not have to install 1000's of libraries in advance in order to compile)

我知道这违反了很好的做法,因为这将是更好的实际安装整个升压 - 但尽管如此参数与其他(少为人知)持有大型图书馆

I know this violates good practice, as it would be better to actually have entire boost installed - but the argument nevertheless holds with other (lesser know) large libraries.

我想这提取很容易被散步根的#include的的#include依赖关系树(如升压/ rational.hpp)来完成;但已经取得了这样的工具?什么是它的名字?

I guess this extraction could be done easily by walking the #include dependency tree of the root #include (like boost/rational.hpp); but has such a tool been made? What's its name?

推荐答案

在Linux下你可以使用×标记为AR以提取所有对象从库中的文件。

Under Linux you can use the "x" flag to "ar" to extract all the object files from a library.

您可以使用纳米,以确定您code需要什么样的符号,它(库)的目标文件中定义它们。 (有一个可选的 - 还原函数的标志,这可能有助于人类的读取输出)

You can use "nm" to determine what symbols are needed by your code, and which (library) object files define them. (There is an optional --demangle flag, which might help human's reading the output.)

您可以再建立一个由只是你所需要的目标文件的一个新库。 (通过AR ranlib的。)或者只是编译(链接)他们直接在命令行上。

You could then build a new library consisting of just the object files you needed. (Via "ar" and "ranlib".) Or just compile (link) them in directly on the command line.

这是脚本的一个简单的问题,以找到您(编译)对象code缺少的符号,然后该对象从库文件中定义它们。然后当然是什么符号从需要其它的库文件的库对象文件...以及从这些新的库(对象)文件丢失...等等的那些失踪。等等。

It's a simple matter of scripting to find the symbols missing from your (compiled) object code, and then which object files from the library define them. And then of course what symbols are missing from those library object files that require other library files... And the ones that are missing from these new library (object) files... And so on. And so on.

它归结为工作很多(通常)太少增益。尤其是当你进入之类的东西弱符号,间接引用,等等。

It boils down to a lot of work for (usually) far too little gain. Especially when you get into things like Weak Symbols, Indirect References, etc.

这篇关于提取大型图书馆的一小部分(FX提升)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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