Compiling simple Hello World program on OS X via command line

后端 未结 8 1013
梦如初夏
梦如初夏 2020-12-22 16:35

I\'ve got a simple hello world example that I\'m trying to compile on OS X, named hw.cpp:

#include 
#include 
usin         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 17:11

    Try

    g++ hw.cpp
    ./a.out
    

    g++ is the C++ compiler frontend to GCC.
    gcc is the C compiler frontend to GCC.

    Yes, Xcode is definitely an option. It is a GUI IDE that is built on-top of GCC.

    Though I prefer a slightly more verbose approach:

    #include 
    
    int main()
    {
        std::cout << "Hello world!" << std::endl;
    }
    

提交回复
热议问题