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 <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
}
g++ hw.cpp -o hw
./hw
user@host> g++ hw.cpp
user@host> ./a.out
Compiling it with gcc
requires you to pass a number of command line options. Compile it with g++
instead.
The new version of this should read like so:
xcrun g++ hw.cpp
./a.out
Also, you can use an IDE like CLion (JetBrains) or a text editor like Atom, with the gpp-compiler plugin, works like a charm (F5 to compile & execute).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With