[Libav-user] reduce dll size

Michael Chisholm chisholm at mitre.org
Tue Mar 25 20:45:07 CET 2014


On 3/25/2014 3:51 AM, Alex Cohn wrote:
> On Tue, Mar 25, 2014 at 4:40 AM, YIRAN LI <mrfun.china at gmail.com> wrote:
>>
>>> I'm trying to build all components into one dll, because my manager
>>> insisted that building into a single dll may save space by avoiding
>>> build duplicated code into separate dlls.
>>
>> How is this supposed to work?
>>
>> Or, to rephrase: What are the duplicated code parts that you found
>> in different FFmpeg dlls and how much (in %) did they take of the
>> overall space?
>>
>>>> Hi Carl,
>>
>> I found that every dll links to libm, if it's a static lib (I can only find .a on my system), does that mean
>> some code will be built into every dll?
>
> Yes, there definitely is some amount of duplication with multiple
> DLLs. You can easily find the amount of overhead, in a supported way.
> Build your project with static version of ffmpeg libraries, and
> compare the size of your binary with the size of binary you have now
> (which is built with libavcodec.dll, libavformat.dll, etc.). For the
> latter, sum up all the DLLs that you need to deploy.
>
> If you find that the difference is significant for your project, only
> then it's worthwhile to work on reducing the size of DLLs or the
> amount of code duplication.
>
> As CameraMan mentioned above, the monolithic binary may require
> special considerations re ffmpeg license, but again, it would be wise
> to delay these discussions until you have an evidence that the simple
> way (with multiple DLLs) can be shrinked down significantly.
>

Aha, I just sent a mail saying it's all a bunch of *.o files regardless 
of how you split them up into libraries.  I'd be interested to know how 
this eliminates dupe code.

It seems to me, what you may gain by linking to a static lib, is that 
only that library code which is actually used by the app is pulled in to 
the exe (right?  It pulls in some subset of the *.o's from the *.a).  If 
you bundle all the DLLs, you include everything that was compiled into 
the libraries, whether the app actually uses it or not.  That's a good 
point, but I don't think it's about code duplication, is it?

(and sorry, just realized I'm mixing windows terms and *nix terms... 
*.o's and *.a's with DLLs... but you get the idea :)

Andy




More information about the Libav-user mailing list