Eclipse CDT C++ CMake on Mac

Using Eclipse CDT on mac along with the g++ compiler is a very good option if you know your Eclipse hotkeys from programming in Java for example or if you are looking for an alternative to XCode.

Eclipse CDT allows you to create CMake projects. This post sums up the traps I got caught up in before getting everything to work in the hopes it will help others to not make the errors I made.

On your Mac, first install cmake and ninja

brew update
brew install cmake
brew install cask cmake
brew install ninja

If the brew commands fail, try repeating them, this sometimes fixes install issues.

Next, start Eclipse CDT from the console instead of from the finder (CMD + space). To start Eclipse CDT from a console, execute the command

open -a EclipseCDT.app

Opening Eclipse CDT from the finder will not add /usr/local/bin to Eclipse’s Path! Opening Eclipse CDT from the command line will add /usr/local/bin to Eclipse’s Path. /usr/local/bin has to be part of the PATH as only then can Eclipse CDT execute ninja and cmake. This is summed up in the post: https://bugs.eclipse.org/bugs/show_bug.cgi?id=532419

You are now able to create a new C/C++ CMake project from within eclipse, clean it, build it and run the executable.

Leave a Reply