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?
You should not focus on the options but on what you want to achieve. My general comments regarding what you want to achieve:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With