Sep 6, 2013 - However, I could not find any resource that properly tells me how to install gcc in mac as a prerequisite for developing C/C++ code in eclipse. GCC on Mac Turn on the terminal within Mac OS X (or Linux) On Mac, run the following command from your terminal to install GCC (if you don’t have it already) xcode-select --install Assume that we have a C source file “hello.c”. You can compile “hello.c”into an executable file called “hello” by the following command.
. Configure the plugin installation. In the Work with: drop-down, select the version of Eclipse you downloaded (for example “Kepler”). As seen in label mark 1 in picture.
In the search field, type Hardware as seen in label mark 2 in picture. Click the check-box to select the C/C GDB Hardware Debugging plugin as seen in label mark 3 in picture. Click the Next button, as seen in label mark 4 in picture and accept the licensing agreement to complete the installation. You will need to restart Eclipse when the plugin installation is complete. Elf. Select C/C BuildTool Chain Editor in the left pane of the Properties dialog box.
Set Current builder to CDT Internal Builder. Click Apply and then OK to close the Properties dialog box. Click the build icon in the toolbar or select ProjectBuild Project in the workbench view to create an elf executable of your project.
Verify your project builds successfully. The Console tab displays Build Finished if the build completes successfully, as shown in the following image.
In the next section of this tutorial, you prepare to run and debug the ELF executable on your Armstrap target. In the Debugger tab,. Under, GDB SetupGDB Command, enter the full path to the location of arm-none-eabi-gdb that was downloaded with GNU Tools for ARM Embedded Processors. This should be /Desktop/armstrap/gcc-arm/bin/arm-none-eabi-gdb, as seen in label mark 1 in picture. Under Remote Target, uncheck Use remote target, as seen in label mark 2.
In the Startup tab, under the Initialization Commands:. Uncheck Reset and Delay (seconds) option.
Check Halt option. For Apple Mac OSX machines, enter the following start-up script.
Click the debug toolbar and select your debug configuration to start flashing and debugging your Armstrap board. If this is the first time you are debugging, you may be presented with a confirmation dialog to confirm the perspective switch. Check the Remember my decision option and click the OK button.
By default, Eclipse will halt on the first line of code, usually the ResetHandler. Click on the F8 key or the green Play button to continue. The execution should stop at your breakpoint (as seen below) and you should be able to debug your target.
Out of the box, OS X Lion doesn’t have the command line C compilers. Plus, Apple has once again changed the way you install those compilers in /usr/bin.
Here’s how to do it with the latest Xcode and Lion. Back in August, right after OS X 10.7, Lion, shipped, I wrote about how a new installation does not have the C compilers in the expected place, /usr/bin. This article, “” provided all the background. Recently, professor Ulf von Barth of Lund University in Sweden alerted me to the fact that the mechanism has changed yet again. In the article linked above, I explained that all you had to do was download and install Apple’s Xcode IDE, and everything would be as expected. Now, you have to do a little more.
But before I proceed, you should go back and read that article for reference on the C compilers, gcc, llvm, and all that jazz. Motivation There may be good reasons not to have a C compiler sitting around an average user’s Mac, ready to stir up trouble if accessed by malware. Thats why it’s not in the Mac by default. On the other hand, you may be taking a C class and want to use a C compiler (gcc now points to llvm) from the command line. Or you may be an administrator, and you want the C compiler to be available in a lab setting. Or you’re a researcher, and you don’t use Xcode for scientific computing.
Or it may just be for show. Some day, an IT admin will come up to you and question you about the Mac, and you proudly announce that it’s based on (BSD) UNIX.
This Linux guru will open the command line, type “cd /usr/bin;./gcc -v” and then snort. Nothing there. It’s not real UNIX!
For whatever reason you may have, here’s what you need to do nowadays. Note that, unlike before, when everything was free, you will need to be a registered Mac developer. Download Xcode, now at version 4.3.2, just as before, from the Mac App Store.
Finder - Apple - App Store It’s always been free and still is. Launch the Xcode.app that was downloaded to /Applications. If you stop there, you’ll find that, unlike before, the command line compilers are not installed by default. You can go hunting for them, and you’ll it all in: /Applications/Xcode.app/Contents/Developer/usr/bin Oops. Gcc/llvm now buried /Applications for use by Xcode Phew! That won’t do you any good unless you intend to use Xcode exclusively.
Very likely, all your conventional Make scripts won’t know where to find the C compilers (and linker and assembler) now, and you wouldn’t want to modify them anyway. So setting up links to the new location would be messy and likely will not work, creating new headaches. What you need is everything back in /usr/bin like before. After launching Xcode, go to Preferences and select the Downloads pane, then Components.
There, in the list of candidate items will be the Command line tools. Click “Install.” Xcode’s downloads 5. You’ll be prompted for your developer credentials then you’ll see the classic progress bar. When that’s done, the C compilers will all be in /usr/bin, as desired. To prove that all’s well, open a terminal window, cd to /usr bin, and take a look.
All is well again in /usr/bin It’s a shame we have to go through all that these days, but I can see how Apple feels that the majority of users don’t need these tools, and those who do will find out how to get them. I suppose you could call that a subordinate claws. My thanks to Dr. Ulf von Barth of Lund University in Sweden and Dr.
Gaurav Khanna, Physics Dept., the University of Massachussetts for their assistance with this article.