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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:02:42+00:00 2026-06-11T05:02:42+00:00

I am not quite familiar with g++ compilers, especially the options, e.g., -s, -g,

  • 0

I am not quite familiar with g++ compilers, especially the options, e.g., -s, -g, and -O.

Firstly, can I ask when do these options take effect? During compile or link phase? I normally put all the options I need in both phases.

Secondly, are there -g1, -g2, -g3 options? I know -g adds debugging info in the to executable. How do others differ?

Thirdly, what does -s do? Do -s, -g, and -O3 work together? My target is to make the executable 1) run quickly, and 2) have small size if possible. What do you suggest?

  • 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-06-11T05:02:44+00:00Added an answer on June 11, 2026 at 5:02 am

    You should not focus on the options but on what you want to achieve. My general comments regarding what you want to achieve:

    • usually there is a trade-off between fast and small. -O3 means fast. Os means as fast as possible without increasing the size.
    • you can use debug information (-g) with optimization (-O3), but the information is poor sometimes as there is not a direct connection between the source and the resulted code
    • if you strip the debug information (-s) from the executable, you will not be able to debug that executable easily (you can have the debug information saved separately but this is another story)

    Always use the manual (accessed by typing in a shell “man g++”, or by searching on the internet “man g++”) and search for the options if you are curios what it does. If you have a higher level question, then you can ask (for example the difference between -g1 and -g3 is explained in the manual)

    As a suggestion: use -O3. If you develop constantly the program and use GDB as debugger use: -ggdb -g3.

    Edit: Regarding on when to apply them: usually you do not worry about phase it is, you just send the options and the g++ takes care of them. When you will want something more specific, then you can check more.

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

Sidebar

Related Questions

I'm really annoyed by const keyword these days, as I'm not quite familiar with
I'm not all that familiar with jquery so I'm not quite sure how to
I'm not quite familiar with asp.net ajax, so my question might be a silly
Really basic (and probably quite idiotic) question but I'm not familiar with this procedure
(note: I'm quite familiar with Java, but not with Hibernate or JPA - yet
I'm quite familiar with UML for modeling object-oriented applications. However, I'm not familiar with
I've read some Q&As about self-balancing binary trees, but I'm not quite familiar with
I'm not so familiar with NoSQL databases, and I'm not quite aware of their
This question may sound familiar but not quite the same as asked before. I
Not quite sure how to go about describing what it is I'm trying to

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.