You can give a name for the executable like this:
Code:
g++ -o helloworld helloworld.cpp
It's also a Good Idea to compile with -Wall, as this gives warnings about lots of questionable constructs:
Code:
g++ -Wall -o helloworld helloworld.cpp
I always cringe when somebody retypes the gcc/g++ command line over and over again: use a Makefile. Just write something like this into a file called Makefile in the same directory as your code:
Code:
CXX = g++
all: helloworld
helloworld: helloworld.cpp
$(CXX) -Wall -o helloworld helloworld.cpp
*NOTE: That must be a TAB character before $(CXX), not spaces!
Once you do this, you can just type
to build the executable, and g++ will only be run if helloworld.cpp was modified after helloworld. Your project can get much larger and compile into separate object files with special flags and so on, but if you keep your Makefile good, all you ever have to do to compile it is type "make". Makefiles get much cooler and much more complicated: type "info make" to read about it. You might want to "info info" first if you haven't used the info doc system before.