I think that learn to use g++ from command line (at basic level... I am not expert too on using g++) helps you to understand better how compilation works, becouse you are forced to understand every step you are doing.
However I cannot answer deeply to your question, in this starting step. Now I will explain what I mean...
"What compiler is better...?" -> it depends of situations. I don't use visual studio becouse I am more oriented to develop platform-independant applications but also becouse I hate the fact I am forced to register it to activate it.
But, saying that, if you develop win-only applications, perhaps visual studio is a good choice.
Another problem: unlike linux, windows is not well suited for compilation. You need to work and setup your compile-toolchain (setting path variable accordingly, etc etc).
So, when you try to use gcc/g++ you can be discouraged becouse: 1) You must find a Mingw-gcc version up to date (2) you must "configure path and MINGDIR" (3) gcc and gdb themselves are not so easy to use, at start.
The advantage of gcc is.... it is supported both in linux (default compiler) and Mac.
Another advantage is that it is recognized by scons (google... to see what scons is).
Perhaps scons recognize also Visual Studio, probably (I don't know) if you try to provide an "independant" building script
But... also becouse of configuration problems, sometimes can still be easier to provide a personal Makefile (ready to use) to compile your own windows version...
.....so, after this short introduction... you can have a little view of possible problems.
If you are interested I can provide you a little guide here for the VERY VERY basic usage og g++
----------------------------------------
G++ VERY Basic Use
----------------------------------------
I - Compiling
-----------------------------------
|
g++ -c -o module.o module.cpp
|
This first example shows you the first 2 options to know when you compile.
-c: this options says that g++ will compile only (so no linking phase at the moment)
-o <name>: this option specify output file name (in this case module.o)
module.cpp: the actual parameter outside options.... the file to process (sourcefile)
|
g++ -c -DDEFINED_MACRO -I. -I"c:/mylib_dir/include" -o module.o module.cpp
|
This example is a bit more complex. It will use also -D and -I options
-D and -I requires that you specify their parameter WITHOUT ANY SPACE
so... IMMEDIATELY after -D and -I you must specify the option
so...... -DDEFINED_MACRO means that "DEFINED_MACRO" is the parameter of option -D
and the same for -I (note: in the second example I used quotes... they are usefull if your directory contains spaces)
now the meaning
-D: defines a macro.... in my example with -DDEFINED_MACRO I obtain the same result like as I wrote "#define DEFINED_MACRO" inside module.cpp (or one of its headers). This option is useful when you must distinguish DEFINES, for example, depending of OS used
-I:add an include path. Very much used (more used than option -D) and very useful. In my example I added 2 include paths (one for every -I)... the first one is "current directory" (so... where module.cpp is)... all headers inside those directories will be found also using #include <FILE>
--------------------------
Linking
--------------------------
|
g++ -o test.exe module.o main.o
|
The grammar is always the same... in this case we will NOT use option -c (becouse it is linking phase) and we will produce "test.exe"
The interesting thing is that sources are multiple here... so it will be simply a list of (precompiled) .o files
|
g++ -L. -lmylib -o test.exe module.o main.o
|
the two options more used are -L and -l
-L specify a PATH where to find a library (in my example library will be searched also in current directory)
-l specity the library to link to. With -lmylib gcc will search for a mylib.a or mylib.dll (under windows) in your library paths, including the current dir (added with option -L)
----------------
for the moment I would avoid optimization, etc etc. I think it is enough to start.