Even though there are a lot of IDEs for Mac OS that might be better than Code blocks, I would suggest you use Code blocks to maintain compatibility as we progress through this course. But it’s not necessary. If you feel like any of the other IDEs like Xcode, Visual Studio or Eclipse is a more comfortable platform, by all means, use that. In this short tutorial, we’ll guide you to setup Code blocks on Mac OS X.
The latest Code blocks v16.01 is not available for Mac OS because, as the team behind the IDE put it, they don’t have developers to make one.
So head on to codeblocks.org and download the version that is already available. You can directly download the bundle here.
Let’s get started with the installation
Step 1: Unzip the compressed file and then launch the Code Blocks application. This should take a few seconds.
Step 2: Because of your Mac’s security, you won’t be able to install Code Blocks right away and this window will pop-up. Click okay and move on to the next step.
Step 3: In your System Preferences, you’ll find the option to override this security. Click on Security and Privacy.
Step 4: The window will automatically show you the applications that were blocked from installing. Click on Open Anyway to resume installing Code Blocks.
Step 5: Two-level authentication. Your Mac will ensure whether you want to open it or not. Click Open.
Step 6: Once the installation resumes, and if you don’t have Xcode, you’ll be prompted by this message. Click on Get Xcode.
This will take you to the Mac AppStore. Here, after entering your Apple ID and Password you’ll be able to install Xcode for free. Depending on your Internet Speed, it could take some time to download and Install the 4.5gb application.
Step 7: Once Xcode is installed, head back over to Code Blocks and start a new project. Opt for a console application from the different templates available and select C as the language.
Step 8: Select the path where you want to save your file.
Let the compiler settings stay at their default values.
Check the management tab on the left if you can’t locate your main.c file. It should be under the Workspace drop-down. Write the HelloWorld code in the main.c file. Click on Build and Run from the toolbar and your Mac should launch the Terminal with the executed code.
If you’ve any troubles installing your new Code Blocks on Mac OS or even Windows, let us know in the comments section below and we’ll try to help you out!
What’s the easiest way to execute C programs? Do I really need an IDE?
If you just wish to execute some code and don’t want to deal with any installations of any IDE, you can use online IDEs. The OnlineGDB IDE for C and C++ is my favorite. Yes, you can execute entire programs from the comfort of your browser.