The Compiler is usually used on command line. The Debugger is running as command line version idbc or the graphical version idb (using JRE). I strongly recommend to not integrate the IDB Debugger to Eclipse since the graphical Debugger idb is already a Eclipse-Framework based solution.
Installing G++ on a Mac

Dev-C for Mac has not been released by Orwell so far, so you can't use it if you switch to Mac. However, there are many C/C compilers that can easily replace all functions of Dev-C for Mac. With the help of this list of alternatives, you can find similar software to. The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 375 open source projects, including runtimes, tools and frameworks. Your question title is asking about compilers, yet you were actually interested in IDE (Integrated Development Environment). I will just assume you actually meant IDE. If you are on Mac, Xcode is generally not a bad choice as it is able to handle.
This section is intended to get you quickly started with C++ programming on your Mac. We'll be installing GCC 4.8.1 and GDB through a tool called Homebrew. If you want an additional guide on all of the following steps (except for installing GCC), the one by Moncef Belyamani is quite helpful. When you follow it, ignore anything about installing Ruby; that is, stop after setting up git.
Homebrew
Homebrew 'installs the stuff that you need that Apple don't'. It's like Ubuntu's apt-get, where one can install packages easily from repositories. Instead of having to download, configure, and install something yourself, all you need to do is run one command, and Homebrew will take care of the rest for you.
Pre-requisites
Homebrew requires that you have either Xcode or the Xcode command line tools installed on your Mac. Xcode is a free integrated development environment similar to Eclipse designed by Apple and mainly intended for iOS development or targeting the clang
compiler. In this class, we will focus on gcc
.
Xcode is quite a big install, so if you do not want to install it, you can get away with just installing the Xcode command line tools. See a Stackoverflow discussion for instructions on how to install the command line tools regardless of whether you have Xcode installed.
Installing Homebrew
You need xcode command line tools to install Homebrew. It is very easy to install Homebrew. Open your terminal, and run the following command:
If this doesn't seem to do anything, try killing it (CTRL C) and running it again. Or checkout homebrew website.
GCC and GDB
Installing GCC
As mentioned before, installing packages with Homebrew is very easy. First, we will add the repository from which the GCC package is available, so that Homebrew knows where to find the package we want. The repository is at https://github.com/Homebrew/homebrew-versions.
We do this by using the brew-tap
command. Keep your terminal open, and run the following command. (For more information on how brew-tap works, visit the Homebrew docs):
Next, we will actually install the GCC package. Run the following command:
It might take a while before the installation is complete. When done, run the following:
The result should look like this:
USC Wireless Warning
Mac Eclipse C++
Many people have had issues running the brew install
commands while connected to USC Wireless. If you are having trouble, you can either try using a wired connection, a different wireless connection, or do the following:
- Download a homebrew cache
- Open Finder, press CMD (command) + SHIFT + G and type
/Library/Caches/Homebrew
Extract the contents of the .zip you downloaded inside of the folder you opened in the previous step. Do not extract any of the .tar.bz2 or .tar.gz inside of the .zip folder.This should look as follows:
Run
brew install gcc48
in the Terminal as instructed above.
Using G++
To compile with the newly installed G++ compiler, use g++-4.8
.
(Advanced) Aliasing g++
If you prefer calling g++ directly, you can also create a bash alias, as follows:
Put these two lines at the end of the file ~/.bashrc
, and run:source ~/.bashrc
For more information on bash alias, take a look at the GNU Docs.
Installing GDB
Here also we use Homebrew. The following instruction has been taken from GDB on OS X Mavericks and Xcode 5 guide. To install, run the following brew command.
Check if it's installed:
The result should be gdb version 7 or higher.
Codesigning gdb
gdb is not going to debug yet. You'll get an error message like 'please check gdb is codesigned'. You need to create a certificate and sign gdb. By doing so you're telling the operating system that gdb is authorized to attach to other processes for debugging purposes. The following instructions have been taken from this Code Signing guide.
- Open application 'Keychain Access' (/Applications/Utilities/Keychain Access.app)
In Keychain Access, select the 'login' keychain in the 'Keychains' list in the upper left hand corner of the window.
Open the menu item in /Keychain Access/Certificate Assistant/Create a Certificate...
Choose a name ('lldb_codesign' in the example, but you can use anything you want), set 'Identity Type' to 'Self Signed Root', and set 'Certificate Type' to 'Code Signing'. Click 'Create'.
Click continue, continue and done.
Click on the “My Certificates” category on the left side and double click on the new “lldb_codesign” certificate.
Open the context menu for 'Trust' (click the triangle) and change the following:
When using this certificate: Always Trust
Now close this window, and enter your login password to confirm this change.
Option-drag (this meaning holding the option key down and dragging) the new 'lldb_codesign' certificate from the login keychain to the System keychain in the Keychains pane of the main Keychain Access window to make a copy of this certificate in the System keychain. You'll have to authorize a few more times, set it to be 'Always trusted' when asked.
Switch to the 'System' keychain and drag a copy of the 'lldb_codesign' you just made onto the Desktop.
Switch to Terminal and then run the following command (copy paste it!):
sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer
Then right click on the 'lldb_codesign' certificate in the 'System' keychain (not 'Login') and select 'delete' to delete it from the 'System' keychain.
Then reboot your system/computer.
Finally you can sign gdb:
codesign -s lldb_codesign /usr/local/bin/gdb
If this command doesn't work...then panic! Just kidding, be sure that you have gdb installed and that gdb is actually installed in /usr/local/bin. You may want to try 'which gdb' in your Terminal to figure out where it is.
Finally, remove the lldb_codesign.cer file that's sitting on your desktop, and gdb should be working at this point. :)
Install a new version of Eclipse to use with C++
You may want to print these instructions before proceeding, so that you can refer to them while downloading and installing MinGW and Eclipse. Or, just keep this document in your browser. You should read each step completely before performing the action that it describes.
Eclipse: Version 4.5 (Mars)
The Eclipse download requires about 200 MB of disk space; keep it on your machine, in case you need to re-install Eclipse. When installed, Eclipse requires an additional 200 MB of disk space.
Downloading
- Click Eclipse
The top of the following page will appear in your browser.
In this handout we will download Eclipse Standard 4.5 for Mac OS X 64 Bit; if your computer uses Mac OS X (Cocoa), continue below; otherwise look for the pull-down list showing Mac OS X (Cocoa) and instead choose either Windows or Linux and then continue below.
- Click the 64 Bit (under Mac OS X) under the heading Eclipse IDE for C/C++ Developers (the fourth selection from the top).
You will see the following page (don't worry about the name of the institution underneath the orange DOWNLOAD button).
- Click the orange DOWNLOAD button. The site named here, in orange, underneath the DOWNLOAD button: United States - Indiana Unversity (http) is the random one chosen by the download page this time; yours may differ.
This file should start downloading in your standard download folder. This file is about 200 Mb so it might take a while to download fully if you are on a slow internet connection (it took me about 5 minutes over a cable modem). Don't worry about the exact time as long as the download continues to make steady progress. In Chrome progress is shown on the bottom-left of the window, via the icon
The file should appear as
Terminate the window browsing the Eclipse download.
- Move this file to a more permanent location, so that you can install Eclipse (and reinstall it later, if necessary).
- Start the Installing instructions directly below.
Installing
- Double click the file eclipse-cpp-mars-R-macosx-cocoa-x86_64.tar.gz, the file that you just downloaded and moved. It will unzip the file and create an Eclipse application, which appears as
Move this application into the Applications folder and put it on the dock for simple access. Now you are ready to perform a one-time only setup of Eclipse on your machine.
- Double-click the Eclipse icon on the Dock that you just created above.
The following pop-up window will appear
(note it says Eclipse Cpp here, because I already have Eclipse installed for my work with Python, so on my machine I renamed this application Eclipse Cpp.
- Click Open.
The following splash screen will appear
and then a Workspace Launcher pop-up window will appear.
In the Workspace text box, your login name should appear between /users and /Documentsworkspace, instead of my name, richardepattis.
Leave unchecked the Use this as the default and do not ask again box. Although you will use this same workspace for the entire quarter (checking projects in and out of it), it is best to see this Workspace Launcher pop-up window each time you start Eclipse, to remind you where your workspace is located.
- Click OK.
Progress bars will appear at the bottom of the spash screen as Eclipse loads.
Eventually the Eclipse workbench will appear with a Welcome tab covering it.
- Terminate (click X on) the Welcome tab.
You will not see the Welcome tab when you start Eclipse after this first time. You should now see the following Eclipse workbench.
Notice the C/C++ words/icon appear on the top left (in the Window title-bar) and below the upper right-hand corner (beneath the tool-bar).
Xcode

Eclipse Mac C++
In this section we will download/install Xcode. Before downloading Xcode
Eclipse For Mac C++
(this software is free) you must have an itunes account.- Download/Install Xcode by opening a browser and pasting the following url: https://developer.apple.com/xcode/downloads/.
It will pop-up the following Developer window.
- Click the View in Mac App Store > link. It will bring pop-up the following itunes window
- Click the Get button (underneath the hammer). The pop-up window will change to
- Click the Install App button (same location).
When I did this, I received the following message in a pop-up window (because I am running Mac OS 10.9.5).At this point I clicked OK and returned to the original Xcode window, scrolled to the bottom (left), and clicked on the Additional Tools link. I was redirected to login with my Apple ID.
I entered my Apple ID and password and clicked Sign In.
Next a pop-up window with an Apple Developer Agreement appeared; I scrolled to the bottom.I clicked the box binding me to the agreement and clicked the Submit button.
Next a pop-up window with various developer tools appeared. I scrolled down to Xcode 5.1 (dated April 9, 2014) and clicked on the + to disclose the Xcode 5.1.1.dmg link.I clicked this link; note the download occupies 2.1Gb of storage: my download took 30 minutes. Then I double clicked the downloaded .dmg file and a pop-window showed itself briefly.
Then a pop-window window asked me to drag/drop Xcode to the Applications folder.
I dragged/dropped Xcode to the Applications folder, and a pop-up window showed itself during the copying.
Then I repeated these steps for Xcode's command line developer tools. I scrolled to Command Line Tools (OS X 10.9) for Xcode - September 2014 (dated September 1, 2014) and clicked on the + to disclose the link.
I clicked this link; note the download occupies 102Mb of storage: my download took just a few minutes. Then I double clicked the downloaded .dmg file and a pop-window showed itself briefly, followed by the following pop-up window.
I double clicked the icon and the following pop-up window appeared, with the word Introduction highlighed.
I clicked the Continue button, and following pop-up window appeared, with the word License highlighed.
I clicked the Continue button, and following pop-up window appeared
I clicked the Agreee button, and following pop-up window appeared, with the word Installation Type highlighed (it skipped highlighing the Destination Select.
(this image appears to be missing)
I clicked the Install button, and following pop-up window appeared.I entered my password and clicked the Install Software button, and following pop-up window appeared, showing the installation progress.
Eventually, that window was replaced with the following pop-up window with the word Summary highlighed.
I clicked the Close button and terminate the Command Line Developer Tools window.
- Open a terminal and type (don't copy/paste) to its prompt: xcode-select --install as shown below.
I pressed return and following pop-up window appeared
I clicked the Install button, and following pop-up window appeared.
I clicked the Agreee button, and following pop-up window appeared briefly.
When it disappers, the following pop-up window appeared.
I clicked the Done button. Then I closed the terminal window.
- Go the the Launchpad and double click the Xcode icon. The following pop-up window will appear briefly
It is replaced by the following pop-up window.
- Click Open. The following pop-up window will appear
Click Agree. The following pop-up window appeared.
I entered my password and clicked OK. The following pop-up window will appear briefly
It is replaced by the following pop-up window.
Click Open Other and the following pop-up window will appear (yours might have diffierent documents, but it should show the workspace that you created when you started Eclipse). Click that workspace (to select it) and click Open.
KLUDGE: is this necessary? Could I have dismissed this window and still have run the code?
Eclipse Verification
In this section we will Eclipse/C++ is working correctly.- Re-open Eclipse if it is not open.
- Start a new project by clicking on the 'down-pointing' black triangle to the right of the left-most icon on the Eclipse tool-bar (not at the top of the screen, but on the window runnin Eclipse). Fill in the Project Name as test; in Project type ensure Empty Porject is selected; in Toolchains ensure MacOSX GCC is selection. The pop-up window should appear as
Click Finish.
- Right click the test folder and select Source File as shown in the window below.
- Enter trivial.cpp after Source file: as shown in the window below.
Click the Finish button.
- Copy/paste the following text starting at line 8 in the trivial.cpp editor.
- Right click in the *trivial.cpp editor tab and select Save.
The * in the editor tab (meaning the file is unsaved) should disappear.
- Click the hammer (or right-click the test folder and select Build Project) and the Console window at the bottom (click it if it is not active) should show a successful build.
- Right click in the trivial.cpp editor and select Run as and then 1 Local C/C++ Application. The Console window should show a successful run. You can run this application in the future by clicking the right-pointing white triange in the green circle (the leftmost one of the three).
You have now verified the installation of Eclipse for C++.

Comments are closed.