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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:51:52+00:00 2026-05-25T18:51:52+00:00

I have this C++ file: #include <iostream> int main(int argc, char *argv[]) { std::cout

  • 0

I have this C++ file:

#include <iostream>

int main(int argc, char *argv[]) {
    std::cout << "Hello world!\n";
    return 0;
}

After compiling with g++ I get a 913KiB big executable. I was astonished, because I thought g++ would be smart enough to not include any code or data not used by the program from the STL.

Next I used UPX with these settings: upx --overlay=strip. After this the executable size was reduced to 142KiB, a reduction of 85% with no speed penalty (I tested this with more complex, mathematical programs).

According to the upx man page:

An "overlay" means auxillary data atached after the logical end of an executable, and it often contains application specific data (this is a common practice to avoid an extra data file, though it would be better to use resource sections).

I couldn’t find any info that was more specific and was left with the following questions:

– What exactly is this overlay?

– Is it safe to strip?

– If yes, why doesn’t g++ do it, even with -Os?

Contextual information:

  • Windows 7 Home Premium SP1 64 bit
  • MinGW installed with TDM-GCC
  • g++ version 4.5.2
  • Compiling with g++ -Os test.cpp
  • 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-25T18:51:52+00:00Added an answer on May 25, 2026 at 6:51 pm

    -Os optimises the generated code for size, it doesn’t say anything about other non-code segments in the executable file.

    Did you try the -s linker option to strip debug symbols, suggested here?

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

Sidebar

Related Questions

#include<iostream> #includeGlew\glew.h #includefreeGlut\freeglut.h using namespace std; int main(int argc, char* argv[]) { GLint ExtensionCount;
I have this simple code: #include <iostream> #include <fstream> using namespace std; int main(void)
#include <iostream> #include <fstream> #include <string> using namespace std; int main (int argc, char*
I have the following source code in main.cpp: #include <iostream> #include <iomanip> int main()
I have got the following sample: #include <iostream> #include <fstream> using namespace std; int
I have this code which will include template.php file from inside each of these
I have a sample program in a file called helloworld.cpp: #include <iostream> using namespace
// diskbin.cpp : main project file. #include stdafx.h #include <windows.h> #include <iostream> #include <fstream>
I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an
I have this file file.txt which I want to split into many smaller ones.

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.