Wednesday 29 June 2011

Change the name of the ouput file while compiling using bash in ubuntu

Well If you are compiling using terminal in Ubuntu or Kubuntu
Then you must be writing the command as follows:
g++ abc.cpp
Where abc.cpp is the name of my file which i need to compile
and i end up the file named a.out
But when there are other .cpp files in the folder and then compile them, then this one gets overwritten
So, we need to name it which can be done simply by just replacing the above command you wrote with the following command:
g++ -o abc abc.cpp
here you will have an output file named as "abc"
you can write anything you want in place of "abc"
I just like to write the same name to avoid confusion

No comments:

Post a Comment