How to run cpp file on Terminal?

I have a C++ program in a cpp file and would like to run it on the terminal in Unix (Macbook user). I have very little Unix experience, so could anybody please help me with this?

Do I have to set the pwd to the folder in which the cpp file is located? Which commands do I have to use then to run the program?
closed account (Dy7SLyTq)
get gcc for mac, cd to the directory containing the source file, and then compile it. typically what i do is
$g++ -std=c++11 [*.cpp source files] -o [final exe]
however there are many more options that you have, such as level of optimizations and how many warnings you get. i would also make sure to grab the obj-c framework since there is a lot you can do on mac with it
why not just download Xcode from the app store? Its free. Better then using terminal.
closed account (Dy7SLyTq)
Better then using terminal.

says who? i have used a number of ides and keep coming back to gedit gcc and make. ides are fine if they work for you. but being able to interface with the terminal is a very important skill no matter your preference
Topic archived. No new replies allowed.