Stewart Hering
Stewart Hering

Reputation: 304

How to compile and run a C++ program with Eclipse for mac?

I have a simple C++ app writen using the eclipse IDE.

#include <stdio.h>
int main(int argc, const char * argv[]) {
printf("hello world");
return 0;
}

On mac does anybody know how to compile/run this code???

Upvotes: 1

Views: 6353

Answers (2)

coder-don
coder-don

Reputation: 113

I have personally found that Eclipse can be a bit funky when it comes to C++. While Jaybears has already given a great answer, here are some alternatives you could consider for learning C++.

  • The C++ IDE on CodingGround is super useful for compiling simple programs. Its interface is really great for just focusing on the code and not getting bogged down in the complexity of a full-fledged IDE

  • If you're looking for something that runs locally, QT Creator is used by several CS departments (such as Stanford's) for teaching C++ due to its' relative simplicity.

Upvotes: 1

jaybers
jaybers

Reputation: 2211

The simplest way would be to open a terminal windows and go to the directory of your source file and type (assuming you have g++ installed): g++ filename.cpp
To run it: ./a.out

If you want the compiler to be integrated within eclipse, you can see this link on how to build c/c++ projects in eclipse.

Upvotes: 2

Related Questions