Oddities with gcc/g++ linkage
H.J. Lu
hjl@lucon.org
Sun Sep 20 08:30:00 GMT 1998
>
> Hi guys,
>
> I was messing with generating object files and linking them in separate
> phases.
>
> The code I was using is:
>
> #include <stdio.h>
>
> int main() {
> printf( "bool = %u\nshort = %u\nint = %u\nlong = %u\n",
> sizeof(bool), sizeof(short), sizeof(int), sizeof(long));
> return 0;
> }
>
> First test:
> g++ sizeof.c -o sizeof
> strip sizeof
>
> On my machine that gives a binary executable size of 44k!
>
> Second test:
> g++ -c sizeof.c
> gcc sizeof.o -o sizeof -lc
> strip sizeof
>
> On my machine this gives me a binary executable size of 3k!!
>
> Third test:
> g++ -c sizeof.c
> g++ sizeof.o -o sizeof -lc
> strip sizeof
>
> This gives me a larger executable size of 44k!
>
> All three executables works fine.
>
> Can anyone explain such variances in binary size?
>
I have no problems on Linux. Make sure you configued egcs with
--enable-shared.
--
H.J. Lu (hjl@gnu.org)
More information about the Gcc
mailing list