Downloaded Bloodshed devcpp, compiled the Hello example but the exe is half a megabyte!?

D

Dave -Turner

You asked how to get a specific compiler to produce a smaller executable.
That's not a question about the language.
It's a C++ compiler, but I didn't realise everyone here was so anal about
the C++ language being referenced with a C++ compiler (I'm sorry - I'm one
of those weird types who actually uses compilers when using the C++
language). My humble apologies, it's just that I've never come across a
newsgroup so petty as this before in all my years of usenet, but it does
quickly demonstrate how useless this newsgroup is so I thankyou for that -
it'll save me wasting my time again.
 
R

red floyd

Dave said:
It's a C++ compiler, but I didn't realise everyone here was so anal about
the C++ language being referenced with a C++ compiler (I'm sorry - I'm one
of those weird types who actually uses compilers when using the C++
language). My humble apologies, it's just that I've never come across a
newsgroup so petty as this before in all my years of usenet, but it does
quickly demonstrate how useless this newsgroup is so I thankyou for that -
it'll save me wasting my time again.

Here's a suggestion. Ask yourself the following questions.

1. If the answer to your question is pretty much the same, regardless
of the language you use (i.e. Delphi, C++, VB) ... it's OT in
comp.lang.c++. Ask in a newsgroup dedicated to your platform, or in
comp.programming.*.

2. If the answer to your question would not make sense on a different
platform (i.e. Windows vs. Linux) or compiler (i.e. g++ vs. VC++), ...
it's OT in comp.lang.c++. Ask in a newsgroup dedicated to your platform.
 
K

Kai-Uwe Bux

Dave said:
And YES, I have read the FAQs. They were helpful to some degree - my 500kb
executable is now only 268kb.
But that is still ridiculously bloated for a "Hello world" console
program. And yes, I do have "-s" (ie. "Strip Executable") setting, and no
I do not have any debug info included. And yes, I do have "Best
Optimization" setting on. I've gone through all the compiler and linker
settings but can't see anything that would be bloating it out like this.

If I just compile (no optimization, no fancy options) hello world with g++
under Linux, I get an executable of size 8K. If I strip it, it becomes 6K.
If I include debug info, it grows to 55K. The only way I can really bloat
it is by linking statically.


[snip]


Best

Kai-Uwe Bux
 
K

Kai-Uwe Bux

Dave -Turner wrote:

[snip]
How about changing the name to
comp.lang.c++.dont.ask.we're.absolutely.bloody.useless ???

Bad idea. This group is aptly named. Would you also suggest that a book
titled "The C++ Programming Language" should be renamed if it fails to
discuss the various options and settings in your favorite compiler/IDE?

At least then
newcomers would know what this newsgroup is about - I wouldn't have
bothered wasting mine (or your) time if I had've known that this newsgroup
was useless when it comes to c++-related questions.

The reason our answers did not meet your expectations is that your
expectations were wrong. Moreover, you could have known in advance by
reading the FAQ or the welcome message for this group.


Best

Kai-Uwe Bux
 
S

Sherman Pendley

Dave -Turner said:
My humble apologies, it's just that I've never come across a
newsgroup so petty as this before in all my years of usenet

All usenet groups have a charter, and being strict about following the
chartered topic is the norm on usenet; the alternative is a chaotic mess
that really *would* be useless.

Frankly, your lack of knowledge about usenet culture casts a lot of doubt on
your claim to have been using usenet for many years.
, but it does
quickly demonstrate how useless this newsgroup is

Grow up. It's not our fault that you don't know the difference between a
programming language and a compiler.

sherm--
 
S

Sjouke Burry

Dave said:
It's a C++ compiler, but I didn't realise everyone here was so anal about
the C++ language being referenced with a C++ compiler (I'm sorry - I'm one
of those weird types who actually uses compilers when using the C++
language). My humble apologies, it's just that I've never come across a
newsgroup so petty as this before in all my years of usenet, but it does
quickly demonstrate how useless this newsgroup is so I thankyou for that -
it'll save me wasting my time again.
Close the door on your way out, and stay out.
 
D

Dave -Turner

Here's a suggestion. Ask yourself the following questions.

rofl. Sorry I didn't go through the 25-point-checklist before I posted a C++
question about C++.
 
D

Dave -Turner

rofl.
Once again I _apologise_ for asking a C++ question in comp.lang.c++, and
again I didn't realise you guys were so ANAL about C++ questions
 
D

Dave -Turner

Close the door on your way out, and stay out.
Thanks for proving my point about how ANAL you guys are.
 
D

Dave -Turner

If I just compile (no optimization, no fancy options) hello world with g++
under Linux, I get an executable of size 8K. If I strip it, it becomes 6K.
If I include debug info, it grows to 55K. The only way I can really bloat
it is by linking statically.

Ahh, must be a Windows Bloodshed problem then.
 
J

James Kanze

On Oct 30, 4:02 am, "Dave -Turner" <[email protected]> wrote:

[...]
Yes and know. There are general aspects which have to be
considered (and I addressed them). How you control them,
however, is very specific to the compiler. I didn't give an
answer to that for the simple reason that I don't know the
Bloodshed compiler, so I have no idea how you control them. And
a specific answer would be off topic (although I'm sure most
people wouldn't object if it were given in the context of a more
general discussion). You really do need to learn how to invoke
your compiler, and it really isn't an appropriate topic here.
I think you're being too harsh. Kanze gave you an answer that
cut about 50% off the size.

I easily get size differences of 3 magnitudes depending on the
options with g++. I also think that it's probably the wrong
question. Whether I use dynamic linking or static depends more
on what I'm trying to accomplish, and not executable file size.
In general this group is far from useless. In your particular
case a clear answer hasn't popped up yet.

Yes and no. I rather thought that my answer was clear. I
indicated the issues, and the aspects he needs to consider.
There should be documentation with the compiler, which combined
with my answer should largely suffice.
As someone else said, it may just be a problem with the
compiler. I advise being patient. If you don't figure
anything out in a week or two, I won't complain if you ask
again.

If he wants the exact options which he needs to give to the
Bloodshed compiler in order to generate the smallest possible
executable file, then this isn't the right place, and people
will complain. General questions concerning issues which might
affect execution file size, or even questions concerning the
appropriateness of considering such a criteria, are certainly
acceptable, however.
 
J

James Kanze

Erik Wikström wrote in message...
GCC used to make small EXEs, then there was some legal stink
with microslut and the EXE size exploded. ( I have no facts on
this, it's scuttlebutt. <G>).

I don't know about this particular case, but... Whether you link
dynamically or statically has a very big impact on the size of
the executable file. If you link dynamically, you must
distribute the dynamic components with your program. That can
have very important legal implications. In both directions: if
you statically link with a library under GPL (not LGPL), then
you may find your own code "tainted"; if you deliver the library
as a separate product (i.e. the way Sun Studio delivers xemacs),
you might not have the problem, even if you link dynamically to
it at runtime.
I think there might be some info at gnu.org, if you look back
far enough.
If you really need a small EXE, try GCC 2.95.2 (ancient, about
the time of the Roman empire. :-} (unreal, but the GNU/Linux
still recommend 2.95.2 for kernel building. Tons of errors to
correct if you use newer compiler. Been there, done that!)).

As a general rule: the error rate goes down as a product ages.
The most reliable versions are those at the end of life cycle.
(G++ 3.0 was a completely new compiler.)
 
J

James Kanze

If I just compile (no optimization, no fancy options) hello
world with g++ under Linux, I get an executable of size 8K. If
I strip it, it becomes 6K. If I include debug info, it grows
to 55K. The only way I can really bloat it is by linking
statically.

It's even smaller on my Solaris Sparc platform: 7.5KB and 5KB.
But the resulting program won't run unless g++ has been
installed, and the user has set up his path (particularly
LD_LIBRARY_PATH) to use it. To get a generally usable
executable under Solaris, you have to use the option
-static-libgcc (or bundle libstdc++.so with your delivery, and
install it somewhere your program knows about). With the result
that the executable size jumps to almost 100KB. (The situation
is different with Linux, since g++/gcc is "bundled", at least
with the distributions I've seen, and libstdc++.so is installed
in one of the places the system looks by default. I'd still use
-static-libgcc, however, in order to be sure that I got the
right version of the library---the one I'd compiled and linked
against.)

If I specify -static (so that all of the libraries are
statically linked), the executable size shoots up to 3MB---even
more than the OP is seeing. This is not recommended, however,
since by doing this, the program is only executable under the
version of Solaris installed on the machine where I linked (2.8,
in my case); if I allow the compiler to link the system
libraries dynamically, however, it is guaranteed to run on later
versions, and is likely to run on some earlier versions (2.7) as
well.

Which brings me back to my original point: there are more
important issues to be considered than the size of the
executable file.
 
C

coal

Yes and no. I rather thought that my answer was clear. I
indicated the issues, and the aspects he needs to consider.
There should be documentation with the compiler, which combined
with my answer should largely suffice.

Your answer was clear enough. I meant that if he had gone
through what you wrote, but he couldn't reduce the size from
~ 260k, the answer to his question was still not clear. If
one compiler produces a 5k exe and another 260k on the same
input, you'd have to be dense not to question that.
Different defaults between the compilers may account for the
difference, but it could be a problem with one of the compilers.
If he wants the exact options which he needs to give to the
Bloodshed compiler in order to generate the smallest possible
executable file, then this isn't the right place, and people
will complain.

I agree that would be pushing his luck. In my opinion,
the only thing the guy could have done better was ask
first in his compiler specific ng. But if the answer
you get there doesn't cut it, bring it up somewhere
else. I can't think of a more appropriate ng than this
one in that case.

Brian Wood
Ebenezer Enterprises
 
J

James Kanze

Your answer was clear enough. I meant that if he had gone
through what you wrote, but he couldn't reduce the size from
~ 260k, the answer to his question was still not clear. If
one compiler produces a 5k exe and another 260k on the same
input, you'd have to be dense not to question that.

For what definition of "input". As I said, I get anywhere from
about 4KB to 3MB with g++, depending on the compiler options.
If you consider the compiler options "input", then the question
of differences between compilers doesn't make sense: the
-dynamic option will likely cause an error on compilers other
than g++. We then slide off into implementation specific
issues, which aren't on topic here.

My own answer here is to read the compiler documentation. And
if that isn't clear, then change the compiler for one which has
clearer documentation. (And I know, changing the compiler isn't
always an option, and finding the documentation isn't always
that trivial---but most of the more frequently used
compilers---g++, VC++ and Sun CC, at least, have online
documentation which can be consulted. And in those three cases,
the documentation, although not perfect, is quite adequate.)
Different defaults between the compilers may account for the
difference, but it could be a problem with one of the
compilers.

It could be; the way the compiler instantiates templates can
make a big difference (and let's not forget that all of iostream
is templates). But somehow, I doubt it.

Of course, it could be that his compiler doesn't support dynamic
linking, and automatically links everything statically. In
which case, he will have very big executables, and there's not
much he can do about it.

More importantly, of course, one might ask: who cares? About
the size of hello, world, I mean. Typically, the size will be
something along the lines of n*k1 + k2, where n is the size of
the sources. If the problem is k1---if hello, world is so big
because the compiler is generating a 100 KB or so per line of
code, he has a real problem, since realistic applications
(anything from 50KLoc up) won't even fit on the disk. But IMHO,
that's unlikely. It's more likely a case of k2 being
excessively large---200K or more. Which means that the size
won't grow excessively as the application grows.
I agree that would be pushing his luck. In my opinion,
the only thing the guy could have done better was ask
first in his compiler specific ng. But if the answer
you get there doesn't cut it, bring it up somewhere
else. I can't think of a more appropriate ng than this
one in that case.

I have no problem with his initial question here: there are very
definite C++ issues involved, as well as implementation specific
details. I do have a problem with his attitude after
that---that the group is useless because we didn't
(couldn't---at least in my case) tell him the exact options he
needed.
 
J

James Kanze

James Kanze wrote in message...
Bloodshed is Dev-C++ IDE, and defaults to GCC(MinGW).
So, you *do* know the compiler! <G>

So all he has to do is go into a command window or his make
file, and add the options -s -dynamic, and the size should
shrink:). (Of course, he'll have to ask in a Bloodshed
specific group about how to do this from the IDE. The only
IDE's I know are gvim/bash/GNU make and emacs/bash/GNU make.
They're also the ones I'd recommend for any professional
development, since they are 1) extremely powerful, and easy to
use once you know them, and 2) totally portable---I use the same
IDE under Solaris, Linux and Windows. On the down side, that
"once you know them" is a pretty big chunk to bite off when
you're first starting.)

I might add another thought: I'm not too familiar with the
platform, but from what I've been told, under Windows, you have
two types of applications: console applications and windows
applications. I don't know exactly how that works, but if you
link all of the GUI stuff into a windows application, it's going
to be very, very big, even if you don't actually use it. As a
sanity check, if he's under Windows, he should ensure that he's
generating a console application, just in case.
 
O

osmium

:

More importantly, of course, one might ask: who cares? About
the size of hello, world, I mean. Typically, the size will be
something along the lines of n*k1 + k2, where n is the size of
the sources. If the problem is k1---if hello, world is so big
because the compiler is generating a 100 KB or so per line of
code, he has a real problem, since realistic applications
(anything from 50KLoc up) won't even fit on the disk. But IMHO,
that's unlikely. It's more likely a case of k2 being
excessively large---200K or more. Which means that the size
won't grow excessively as the application grows.

Aha! Now I understand. It's like a lawyer who charges a $50K retainer for
defending a double parking case, but only charges $25 an hour. It's all so
simple and sensible ...
 
V

Virtual_X

All usenet groups have a charter, and being strict about following the
chartered topic is the norm on usenet; the alternative is a chaotic mess
that really *would* be useless.

Frankly, your lack of knowledge about usenet culture casts a lot of doubt on
your claim to have been using usenet for many years.


Grow up. It's not our fault that you don't know the difference between a
programming language and a compiler.

sherm--

i think you will need something like UPX it will compress your exe and
if you need more and more
do optimization to your code like remove debug information and use C
"stdio.h" instead of any C++ standard library "iostream.h" that will
give you assembly programs size

the UPX is free and open-source and work in both windows and linux
http://upx.sourceforge.net/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top