在c ++中修剪静态库 [英] Pruning a static library in c++
问题描述
编辑:我忘了提到我使用gcc在cygwin和linux(虽然我想要一个解决方案,工作与visual studio,我们通常使用它为开发,但主要部署在linux)
创建共享库。它的行为就像一个可执行文件从链接的角度来看。它应该做你提到你在可执行文件上看到的废弃。
I am trying to expose a single well defined class by building a static library and then shipping the built library with a few header files that define that class and the interfaces needed to use it. I have that working but the problem I am running into is the library is gigantic. It has every single object file from the whole project and all I need is a subset. If I make a simple main.cpp file and include and use that single class then I get a output file that is only as big as the 20% of the library I am using. Is there a way to tell the linker to start from a given place and prune everything else like in the executable case?
EDIT: I forgot to mention that I am using gcc on cygwin and linux (though I would like a solution that worked with visual studio as well, we generally use that for development but deploy primarily on linux)
Make a shared library. It behaves like an executable from the point of view of linking etc. It should do the discarding you mentioned you saw on the executable.
这篇关于在c ++中修剪静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!