PDA

View Full Version : Same C code different exe sizes: Win32, Linux, and TI-DSP


Vimal
05-17-2007, 10:42 AM
Hi,

I complied a C code on three different platforms: VC++ on Visual
Studio 2005 on Windows XP, GCC on Linux and Texas Instruments Code
Composer for TIC67x simulator.

The final executable sizes differe quite a lot on windows it is 400K,
on Linux 650K, and on TI more than 1Meg.

I will be greatful if someone can direct me to useful urls, which can
explain the differences.

Cheers,
Vimal

Brad Griffis
05-17-2007, 01:31 PM
Vimal wrote:
> Hi,
>
> I complied a C code on three different platforms: VC++ on Visual
> Studio 2005 on Windows XP, GCC on Linux and Texas Instruments Code
> Composer for TIC67x simulator.
>
> The final executable sizes differe quite a lot on windows it is 400K,
> on Linux 650K, and on TI more than 1Meg.
>
> I will be greatful if someone can direct me to useful urls, which can
> explain the differences.
>
> Cheers,
> Vimal
>

The TI output file would all be ascii, not the straight-up binary
executable that you'd get with the others. This will blow up the code
size. Also, depending on the options you're using there most likely
will be symbolic information in there. I think there might be a linker
option to strip all symbolic information. However, you would still have
the code size due to ascii.

Brad

Vladimir Vassilevsky
05-17-2007, 02:58 PM
Vimal wrote:

> Hi,
>
> I complied a C code on three different platforms: VC++ on Visual
> Studio 2005 on Windows XP, GCC on Linux and Texas Instruments Code
> Composer for TIC67x simulator.
>
> The final executable sizes differe quite a lot on windows it is 400K,
> on Linux 650K, and on TI more than 1Meg.
>
> I will be greatful if someone can direct me to useful urls, which can
> explain the differences.

Ah, this is a philosophical question. In depth it comes up to the
following classic problem:

Is it possible to fatten up the wolf so he will have the ass bigger then
that of a bear?

VLV

Donald
05-17-2007, 03:31 PM
Vimal wrote:
> Hi,
>
> I complied a C code on three different platforms: VC++ on Visual
> Studio 2005 on Windows XP, GCC on Linux and Texas Instruments Code
> Composer for TIC67x simulator.
>
> The final executable sizes differe quite a lot on windows it is 400K,
> on Linux 650K, and on TI more than 1Meg.
>
> I will be greatful if someone can direct me to useful urls, which can
> explain the differences.
>
> Cheers,
> Vimal
>
Why are you comparing Apples to Oranges to Bananas ??

Three different compilers with three different libraries !!

Three different op-code sets !!

Of course they would all be different.

Why is this not obvious ??

donald

Kumar Appaiah
05-18-2007, 05:35 AM
On May 17, 2:42 pm, Vimal wrote:
> The final executable sizes differe quite a lot on windows it is 400K,
> on Linux 650K, and on TI more than 1Meg.

Another factor you have to take into account are the compiler flags
and options. For example, gcc has -Os, -O2 etc. each of which affects
the compilation in some way (optimizations for size, loop unrolling
etc.). With different flags, you are sure to get different output
sizes even with the same compiler.

Kumar

Vimal
05-18-2007, 09:41 AM
Hi all,

Thanks for all the responses.

I admit that all the three platforms/compilers are different. However
can there be such a huge difference in the exes.

One of the usual suspect is that Windows might be using some .dlls
while compiling. The C-code is not using any Windows functionality as
such, however there would be some OS related .dlls, and I guess Linux
and TI will statically link everything and include the whole .obj code
in the final executable.

Is there a way to fairly compare, i.e. is it possible to have all the
three executables only linking statically, and is it possible to link
only 1-function rather than the whole file in the final exe for all
the three platforms. The TI code is on simulator with rts.lib used.

Thanks
Vimal
PS: I guess, TI's .out file is a binary file.

Andreas Huennebeck
05-18-2007, 09:56 AM
Vimal wrote:

> I complied a C code on three different platforms: VC++ on Visual
> Studio 2005 on Windows XP, GCC on Linux and Texas Instruments Code
> Composer for TIC67x simulator.
>
> The final executable sizes differe quite a lot on windows it is 400K,
> on Linux 650K, and on TI more than 1Meg.

This is correct.

> I will be greatful if someone can direct me to useful urls, which can
> explain the differences.

Another reason is that usually binaries on Linux and Windows use the
C-library (and often others as well) dynamically linked, while on TI all
libraries are statically linked. If you compile a linux binary with -static
it will be much bigger.

Tschau
Andreas
--
Andreas Hünnebeck | email: [email protected]
----- privat ---- | www : http://www.huennebeck-online.de
Fax/Anrufbeantworter: 0721/151-284301
GPG-Key: http://www.huennebeck-online.de/public_keys/andreas.asc
PGP-Key: http://www.huennebeck-online.de/public_keys/pgp_andreas.asc