Setting up for C

Setting up for C

My last experience in development in “true” C was at least 10+ years ago.  This quarter for my Machine Organization class we’re getting down and dirty with some basic C operations as we develop in Assembly and execute some operations on a virtual ISA.  After spending so much time Java, I underestimated how much time it would take to jockey around my workspace and preferred IDE, Eclipse to get into C.

For most of my time in Java I’ve developed with Eclipse as my IDE, using the latest Kepler release after transitioning from Juno the previous year.  I find myself in the minority of people who like Eclipse, though I’m not doing most of the advanced visual things (Android dev for example) that either Android Studio, IntelliJ, or NetBeans really excel at.  At the end of setting up everything for C, I realized that I have a ton of preferences tweaked and set just so in the app.  Attempting to duplicate this across my two dev machines was a bit annoying but not insurmountable.

Adding in C/C++ support into Eclipse is as easy as hitting up the Marketplace within Eclipse and searching for “CDT” or C Developer Tools.  After installing the required packages, reboot Eclipse and you’re good to go.

Except you’re not.  The current version of Mac OS X is 10.9 otherwise known as Mavericks.  Mavericks doesn’t come with a deployed version of gcc, GNU’s Compiler Collection (formerly known just as GNU C Compiler).  Mavericks instead leverages clang, a newer open-source compiler designed to act as a 1:1 replacement for gcc.  At some later date I’ll compile these apps with clang just to see if I can track a discernable difference, but for now its really no big deal.  Anyway, back to getting gcc installed.  On Mavericks, head to a command line and type in “xcode-select –install”.  You’ll be prompted with a dialog that Xcode needs to install the Command-line Developer Tools.  Voila! Once you have these, you’ll have gcc installed.

The last bit is to actually point the Eclipse toolchain towards the right directory, which can be done under the Preferences menu.

Next time I’ll delve into tweaking Eclipse for Git or SVN repositories.