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 3358736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:47:17+00:00 2026-05-18T02:47:17+00:00

After programming for a while in C, I decided to finally start to learn

  • 0

After programming for a while in C, I decided to finally start to learn C++. This is sort of bothering me, as the standard ‘hello world’ in C is usually ~16KB, including all of the crud your compiler throws on there. (Using stdio)

However, when I create a C++ executable doing hello world, the file is ~470KB! I went ahead and used cstdio instead of iostream, thinking it would make a difference and it did.

My question is:
When I include iostream, why does the size of my executable explode?

Edit: I’m using G++ (With the Dev-CPP IDE, but I can figure out how to add CL paramaters)

  • 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-18T02:47:18+00:00Added an answer on May 18, 2026 at 2:47 am

    In a word, symbols.

    The C++ standard library introduces a lot of symbols to your program, since most of the library exists primarily in the header files.

    Recompile your program in release mode and without debug symbols, and you can easily expect the program to be significantly smaller. (Smaller still if you strip symbols.)

    As a quick demonstration of this fact, observe:

    $ cat hello.c
    #include <stdio.h>
    int main() {
        printf("%s\n", "Hello, world!");
        return 0;
    }
    $ cat hello.cpp
    #include <iostream>
    int main() {
        std::cout << "Hello, world!\n";
        return 0;
    }
    $ gcc hello.c -o hello-c
    $ g++ hello.cpp -o hello-cpp
    $ gcc hello.c -ggdb -o hello-c-debug
    $ g++ hello.cpp -ggdb -o hello-cpp-debug
    $ gcc hello.c -s -o hello-c-stripped
    $ g++ hello.cpp -s -o hello-cpp-stripped
    $ gcc hello.c -s -O3 -o hello-c-stripped-opt
    $ g++ hello.cpp -s -O3 -o hello-cpp-stripped-opt
    $ ls -gG hello*
    -rwxr-xr-x 1  6483 Nov 14 15:39 hello-c*
    -rw-r--r-- 1    79 Nov 14 15:38 hello.c
    -rwxr-xr-x 1  7859 Nov 14 15:40 hello-c-debug*
    -rwxr-xr-x 1  7690 Nov 14 15:39 hello-cpp*
    -rw-r--r-- 1    79 Nov 14 15:38 hello.cpp
    -rwxr-xr-x 1 19730 Nov 14 15:40 hello-cpp-debug*
    -rwxr-xr-x 1  5000 Nov 14 15:45 hello-cpp-stripped*
    -rwxr-xr-x 1  4960 Nov 14 15:41 hello-cpp-stripped-opt*
    -rwxr-xr-x 1  4216 Nov 14 15:45 hello-c-stripped*
    -rwxr-xr-x 1  4224 Nov 14 15:41 hello-c-stripped-opt*
    

    I can’t explain why a Windows build of the programs with G++ produces such large executables, but on any other platform, symbols are the primary driving factor in large file sizes. I don’t have access to a Windows system at the moment, so I can’t test.

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

Sidebar

Related Questions

Lately, I've decided to start using Perl::Critic more often on my code. After programming
After taking a few years off from programming, I decided to start learning vb.net.
After ages of programming in php this question seems really weird still to me.
After doing the whole enterprise programming for a while, I'm seriously disillusioned by the
This has always been on my mind while programming, so I thought I'd spit
I'm new to the development world, I am gradually teaching myself programming after 15
So after a while of programming android apps(1 uploaded on market, have 3k+ active
After programming a little in C I decided to jump right into C++. At
I succesfully used a validator more than once,but after some programming my validators are
I'm working with someone who's looking to get back into programming after several years

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.