Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6965095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:00:34+00:00 2026-05-27T16:00:34+00:00

Last week I found a simple game on the web called killallcops.exe . I

  • 0

Last week I found a simple game on the web called killallcops.exe.
I studied the binaries and wondered why the programm is that big. (About 460k)

So I rewrote the game using iostream

#include <iostream>
int main(){
    std::cout << "All cops are killed.\nCongratulations";
    std::cin.ignore();
    return 0;
}

compiled it with g++ and got 460k too.

I really wondered why this thing was so big and rewrote it using stdio

#include <stdio.h>
int main(){
    printf("All cops are killed.\nCongratulations");
    while(getchar() != '\n'){}
    return 0;
}

compiled it with gcc and got 13k.

I know that iostream has much more abilities than stdio (like typesafety) and thus is itself much bigger, but why does this result in bigger binaries and are there solutions to reduce the size when using iostream, for example only using specific parts of it?

edit: as stated below using gcc 3.4.4 under cygwin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:00:34+00:00Added an answer on May 27, 2026 at 4:00 pm

    I’ll flesh out my comment as an answer:

    <iostream> has a lot of internal dependencies, even for using a simple cout call. It brings in a lot of other code/headers it needs to work (which includes template code and such). Up front let’s say the size of bringing in <iostream> is probably not very significant in a nontrivial application.

    You can trust the compiler/linker to know what they’re doing, but if you want to reduce the binary size, try using options like gcc -s, which strips symbols, or flags like -Os which attempts to optimize the binary for size.

    I suspect a lot of your binary size problems actually comes from something else: a statically-linked libstdc++.

    If you’re using MinGW on Windows, do note that until very recently, their implementation of the GCC toolchain did not have a dynamically-linked libstdc++; instead all C++ builds statically link in libstdc++ which will greatly increase the size of your binaries.

    Here’s a comparison, the size of a binary produced by g++ for your code, on Linux, using GCC 4.6.1. No optimization or symbol stripping was performed on these builds.

    λ > ls -lh a.out          
    -rwxr-xr-x 1 billylee billylee 6.1K Dec 24 10:37 a.out
    

    And here’s one produced by GCC

    λ > ls -lh trial
    -rwxr-xr-x 1 billylee billylee 4.9K Dec 24 10:41 trial
    

    The g++ version is a little larger than the gcc version, but not 100x larger.

    edit: If you’re using MinGW – there’s a recent thread here: How to reduce the size of executable produced by MinGW g++ compiler?

    MinGW gcc 4.5.0+ should use dynamic linking by default, check your version if you are using MinGW.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following a server move last week I have found that all the Facebook iframe
I'm working with Websphere Portal and Oracle. On two occasions last week, I found
Last week we released Omniture's analytics code onto a large volume of web sites
I've spent the last week developing code to connect to a Web Service using
I was writing some Unit tests last week for a piece of code that
I replaced ActivePerl with Strawberry Perl on my WinXP last week. I found I
I spent a good portion of time last week working on serialization. During that
I created a simple function to get first and last day of a week
Last week I published app, this app contained just video links that allows the
I've built this website last week, which has worked perfectly across all browsers that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.