kgrimes2 kgrimes2 - 1 year ago 98
C++ Question

Compiling C++ Program from Mac Command Line

I have 3 files: main.cpp, myheader.h, and myheader.cpp.

I would like to compile and execute main from the command line, but I am not sure how to go about this.

Any help would be appreciated.


Answer Source

For anyone interested, one of the ways to compile a program is as follows:

g++ -o executableName main.cpp myheader.cpp -std=c++11

You may or may not need the flag at the end.

If you have other cpp files that need to be compiled, just add them where "myheader.cpp" is.

Once your executable has been created, you can run it with

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download