source file name?

i am trying to compile my first c++ program and i am using
c++ -o executable_ filename.out sourcefi lename.cc what is source file name?
on linux its g++ -o foo foo.cpp I hope it helps
Yeah, what Frantz said. Try g++
yes this helps for the most part but for this command were to i put the file name?
Congratulations on attempting to compile your first program. Answers to a few questions may help.

1) What operating system are you using?
2) What compiler do you have?

The general way to compile and link c++ source code is something to the effect of

[compiler_name] [-o final_executable_name] [sourcecode_file_name]

So if you're using the GNU g++ compiler, making a program called "MyProgram" and have the source code in a file called "MySourceCode.cc" you would type:

g++ -o MyProgram MySourceCode.cc

I hope this helps.
Example:
HelloWorld
cpp file: HelloWorld.cpp
executable name: HelloWorld

to run from command line
g++ -o HelloWorld HelloWorld.cpp
Save yourself the headaches and get an IDE. Only masochists envoke gcc directly from the commandline.

Steps to build using an IDE: press F7
thanks guys, that really helps.
Disch wrote:
Save yourself the headaches and get an IDE. Only masochists envoke gcc directly from the commandline.

Steps to build using an IDE: press F7


lol, agreed.
Last edited on
Topic archived. No new replies allowed.