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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:52:44+00:00 2026-05-26T15:52:44+00:00

I have a trivial Hello world C++ program that is compiled to 500kB executable

  • 0

I have a trivial “Hello world” C++ program that is compiled to 500kB executable by MinGW g++ compiler under Win XP.
Some say that is caused by iostream library and static link of libstdc++.dll.

Using -s linker option helped a bit (reducing 50% size), but I would by satisfied only by <10kB executable. Is there any way how to achieve this using MinGW compiler? Portability is not a big concern for me.

Is it possible to copy libstdc++.dll with the executable using dynamic linking? If so, how to achieve this?


Solved: I was using MinGW 3.4. Now I updated to latest MinGW 4.6 and the size was decreased by 90% to 50kB, with -s option even to 9kB, which is fully sufficient. Anyway – thanks everyone for help. Here you go my results

C++ Hello World program using iostream

MinGW | no options | -s option
------------------------------
3.4   | 500kB      | 286 kB
4.6   | 50kB       |   9 kB
  • 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-26T15:52:44+00:00Added an answer on May 26, 2026 at 3:52 pm

    Flags to use:

    • -s like you’ve been doing to strip symbols
    • -lstdc++_s to specify dynamically linking against the libstdc++.dll
    • -Os to optimize the binary for size.

    By default mingw static links to libstdc++.a on Windows.

    Note that the lstdc++_s flag is only in MinGW with GCC > 4.4, I believe.

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

Sidebar

Related Questions

Let's say I have an existing trivial XML file named 'MyData.xml' that contains the
Assume we have a trivial Java program that consists of just one class: public
I have some trivial markup that looks like the following: <li class=someclass> <=% t'model.attr'
I have some trivial code that looks like this: SortedDictionary<String, long> d = new
I have some json files with 500MB. If I use the "trivial" json.load() to
I have some trivial JavaScript to effect a style change: sel = document.getElementById('my_id'); sel.className
I have a trivial little game I wrote in javascript that creates a wave
Lets say that I have 10,000 regexes and one string and I want to
I have a trivial secure socket server-client program. For the server certificates, I created
I have a fairly trivial static variable question. I'm building out a solution 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.