From: Igor R. on
Hello,

I noticed that when I link my application with static libraries built
with MinGW/gcc (like ffmpeg), the apllication size is increased by the
size of these libraries - even though I don't use most of their code.
To verify this guess, I reconfingured and rebuilt the libs, excluding
a lot of unused features - the libs became smaller, and the
application size decreased drastically.
I link in MSVC9.0 in release mode, with /OPT:REF /OPT:ICF.

So is there a way to make the linker drop unused code in this case?
From: Carl Daniel [VC++ MVP] on
"Igor R." <igor.rubinov(a)gmail.com> wrote in message
news:4b1af033-a32d-4631-aa28-c3a937c08666(a)j24g2000yqa.googlegroups.com...
> Hello,
>
> I noticed that when I link my application with static libraries built
> with MinGW/gcc (like ffmpeg), the apllication size is increased by the
> size of these libraries - even though I don't use most of their code.
> To verify this guess, I reconfingured and rebuilt the libs, excluding
> a lot of unused features - the libs became smaller, and the
> application size decreased drastically.
> I link in MSVC9.0 in release mode, with /OPT:REF /OPT:ICF.
>
> So is there a way to make the linker drop unused code in this case?

Two options:

1. The libraries are not properly constructed libraries and the linker is
unable to separate the modules. This seems unlikely.

2. Something about your linker command or the files is causing the linker to
treat these libraries as object files and not as libraries.

I'd suggest linking with /verbose and studying the output for clues.

-cd


From: sasha on
Carl Daniel [VC++ MVP] wrote:

> 1. The libraries are not properly constructed libraries and the linker
> is unable to separate the modules. This seems unlikely.
>

Function-level linking wasn't enabled?

> 2. Something about your linker command or the files is causing the
> linker to treat these libraries as object files and not as libraries.
>


That shouldn't make a difference, I don't think.
From: Igor R. on
The libraries have *.a extenstion, but I don't think this matters.

> Function-level linking wasn't enabled?

Yes, it seems to be something like this. In there such an option in
MinGW/gcc - like /Gy in MSVC? (Well, I know it's better to ask in an
appropriate group, but maybe one of you has the relevant experience.)
From: sasha on
Igor R. wrote:

> Yes, it seems to be something like this. In there such an option in
> MinGW/gcc - like /Gy in MSVC? (Well, I know it's better to ask in an
> appropriate group, but maybe one of you has the relevant experience.)


I'm not familiar with that, sorry.