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

  • Home
  • SEARCH
  • 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

After having read Ian Boyd 's constructor series questions ( 1 , 2 ,
I'm in the process of porting some code from Linux to Mac OS X.
I am attempting to pull some information from my tnsnames file using regex. I
I'm trying to build a Chrome browser extension, that should enhance the way the

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.