构建功能可提取库的最佳方法? [英] Best Way to Build Function-Extractable Library?
问题描述
我正在用C编写Win32静态链接的应用程序。
I'm making Win32 statically-linked applications written in C.
小.EXE是一个目标。
Small .EXE's are a goal.
我试验过对于库项目,似乎链接器可以从库中提取的最小单元是"模块",而不是"功能"。 这将使.EXE比它们需要的更大。
I experimented with a library project, and it appears that the minimum unit that can be extracted from a library by the linker is a "module", rather than a "function". This will make .EXE's larger than they need to be.
对于模块中的大型函数集合(例如,独立整数运算函数的集合) ),有没有办法编译模块,以便链接器可以单独提取每个函数?
For large collections of functions in a module (a collection of independent integer arithmetic functions, for example), is there any way to compile the module so that each function is individually extractable by the linker?
如果答案是"否",那么我可以将事物拆分成一个函数每个模块或使用预处理器基于预处理器开关一次编译一个函数(我已经看到很多这样写的库),但我想知道是否有
更方便的方法。
If the answer is "no", then I can split things up into one function per module or use the preprocessor to compile one function at a time based on preprocessor switches (I've seen many libraries written this way), but I was wondering if there is
any more convenient method.
谢谢!
推荐答案
On 7/17/2018 1:52 PM ,David T. Ashley写道:
On 7/17/2018 1:52 PM, David T. Ashley wrote:
我试验了一个库项目,看来链接器可以从库中提取的最小单位是"模块",而不是"功能"。这将使.EXE比他们需要的更大。
I experimented with a library project, and it appears that the minimum unit that can be extracted from a library by the linker is a "module", rather than a "function". This will make .EXE's larger than they need to be.
您可能正在寻找
https://docs.microsoft.com/en- us / cpp / build / reference / gy-enable-function-level-linking
这篇关于构建功能可提取库的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!