How can I compile/run C or C++ in Unix console or a Mac terminal?
(I know it, forget it, and relearn it again. Time to write it down.)
For running c++ files run below command, Assuming file name is "main.cpp"
1.Compile to make object file from c++ file.
g++ -c main.cpp -o main.o
2.Since #include
does not support in MacOS so we should use its alternative which supports in Mac that is #include
. Now object file needs to be converted to executable file. To use curses.h
we have to use library -lcurses
.
g++ -o main main.o -lcurses
3.Now run the executable.
./main