Oct 19, 2011 at 1:56am UTC
i am trying to compile my first c++ program and i am using
c++ -o executable_filename.out sourcefilename.cc what is source file name?
Oct 19, 2011 at 2:33am UTC
on linux its g++ -o foo foo.cpp I hope it helps
Oct 19, 2011 at 2:36am UTC
Yeah, what Frantz said. Try g++
Oct 19, 2011 at 4:59pm UTC
yes this helps for the most part but for this command were to i put the file name?
Oct 19, 2011 at 5:10pm UTC
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.
Oct 19, 2011 at 10:04pm UTC
Example:
HelloWorld
cpp file: HelloWorld.cpp
executable name: HelloWorld
to run from command line
g++ -o HelloWorld HelloWorld.cpp
Oct 19, 2011 at 10:09pm UTC
Save yourself the headaches and get an IDE. Only masochists envoke gcc directly from the commandline.
Steps to build using an IDE: press F7
Oct 20, 2011 at 1:17am UTC
thanks guys, that really helps.
Oct 20, 2011 at 1:28am UTC
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 Oct 20, 2011 at 1:28am UTC