g++Released by the Free Software Foundation, g++ is a *nix-based C++ compiler usually operated via the command line. It often comes distributed with a *nix installation, so if you are running Unix or a Linux variant you likely have it on your system. You can invoke g++ on a source code file simply by typingg++ filename The default executable output of g++ is "a.out". It is also possible to specify a name for the executable file at the command line by using the syntax -o outputfile, as shown in the following example: g++ filename -o outputfile Catching Problems EarlyIn order to compile with all warnings enabled and to produce standards-compatible C++ code, I recommend using the flags-Wall -ansiYou can read more on the value of compiler warnings. If you want to have the compiler treat warnings as errors--meaning you don't even get an executable, you can use the -Werror flag. This will make sure you don't miss an error. GDB Ready CodeIf you want to prepare your executable for use by GDB, include the -g flag.g++ filename -g -o outputfileThis will enable GDB to give you detailed debugging information by including extra code in the executable file to allow GDB to find variable names and list the source code. Find Out MoreIf you are using a *nix system, you can also check out the other g++ commandline options by typingman g++ Creating shared librariesIf you want to learn how to create a shared library on Linux with GCC, check out the article how to create a shared library on Linux using GCC |