Install Code Blocks on Mac OS X and run your first C program

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.

UPDATE: If you have upgraded your macOS to the latest Catalina version you won’t be able to run CodeBlocks since it is not updated to be compatible with Catalina. Apple ended its support for 32-bit apps with this update. However, if you still wish to run CodeBlocks, you can either downgrade to Mojave or run Mojave on a separate volume.

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.Code Blocks on Mac OS

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.


About The Writer

Leave a Reply

Your email address will not be published. Required fields are marked *

8 comments

  1. Hello Umair!
    Mac just launched a new OS, Catalina. I tried to do what you suggest in this article, but one legend appears, saying, “The developer needs to update the App to work in this new macOS version.” Do you know what can I do to get CodeBloks updated? Thanks. Regards

    1. Hi Pilar
      So this is going to be an issue for Mac users from October. 32-bit app support has been disabled with the Catalina update. There’s really nothing you can do right now except downgrading to Mojave or running Mojave on a separate volume because CodeBlocks has not updated its macOS version yet.

  2. Trying to use it on current OS X (Mac Mini 2012 Quad i7) for both C and C++… Having some issues with the compile and debug which are probably related to the pathing or something… Did The XCode from the install… but I did already have XCode installed… Also, did a manual of the CMD Line… Doesn’t seem to be working without me modifying things… Environment looks fine just the compiler/debug calls failing like so:

    ————– Build: Debug in TEST002 (compiler: GNU GCC Compiler)—————

    gcc -Wall -g -c /Users/otterbox/Projects/TEST002/main.c -o obj/Debug/main.o
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

    I don’t plan on doing a whole lot with this… Mostly making a few file manipulation programs and maybe attempting to access iTunes as a data source to manipulate some metadata… but I would gladly help you test it… BS Comp Sci… Working since 12 on programming (Apple II lol) and sort of went out of programming at VB6 into just DB work in SQL/Reporting Tools… So, I do have a lot of industry skill; however, I am out of practice…

    1. After installing the gcc with the Xcode, try running “gcc -v” via the terminal. It should give you a clue as to whether gcc has been properly installed.

  3. Please kindly help me sort out this issue on my code block installations

    I got the code blocks and the command line tool installed but when i ran the main.cpp default hello world program, I got this on the build logs:

    ————- Run: Debug in test (compiler: GNU GCC Compiler)—————

    Checking for existence: /Users/Imesconsult/Documents/C++ Programming/test/bin/Debug/test
    Executing: osascript -e ‘tell app “Terminal”‘ -e ‘activate’ -e ‘do script “/Applications/CodeBlocks\ 2.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Imesconsult/Documents/C++\ Programming/test/bin/Debug/test “‘ -e ‘end tell’ (in /Users/Imesconsult/Documents/C++ Programming/test/.)
    Process terminated with status 0 (0 minute(s), 0 second(s))

    and Terminal Displayed
    Last login: Fri Mar 2 15:40:35 on ttys000
    Imehs-MacBook-Pro:~ Imesconsult$ /Applications/CodeBlocks 2.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Imesconsult/Documents/C++ Programming/test/bin/Debug/test
    -bash: /Applications/CodeBlocks: No such file or directory
    Imehs-MacBook-Pro:~ Imesconsult$ ;2D

    But when I did the verify command line tool after installations I got
    Last login: Fri Mar 2 15:43:11 on ttys001
    Imehs-MacBook-Pro:~ Imesconsult$ gcc -v
    Configured with: –prefix=/Library/Developer/CommandLineTools/usr –with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 7.0.2 (clang-700.1.81)
    Target: x86_64-apple-darwin14.0.0
    Thread model: posix
    Imehs-MacBook-Pro:~ Imesconsult$

    Please help me so I can get started…

    1. You may have some other version of the GNU installed on your workstation that is corrupting the files for this install. Check for a file named cc1.exe in this path /libexec/gcc/i686-w64-mingw32/4.6.3. Let me know if you find it. This is intriguing.

  4. Hello!

    i’ve installed the code 13.12 into a macOSX 10.13.3 but it’s not compilated. It appears

    /Users/johnmoyano/Desktop/Screen Shot 2018-02-23 at 9.56.00 PM.jpg

    /Users/johnmoyano/Desktop/Screen Shot 2018-02-23 at 9.56.35 PM.jpg

    Can you hele please!

    1. I am sorry I cannot access your image links since those are for the local system. Can you please copy and paste the error message that you are getting in the terminal?