View Course Path

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.

CODEBLOCKS CATALINA 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.

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 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.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.

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

  1. Hi Umair! Hope you’re having a good day!

    I installed codeblocks and xcode, I’m trying to run an int code but it’s not running properly. It shows this in the terminal:

    /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/mirzashuja/Desktop/assignment icp/bin/Debug/assignment icp
    ➜ ~ /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/mirzashuja/Desktop/assignment icp/bin/Debug/assignment icp
    sh: /Users/mirzashuja/Desktop/assignment: No such file or directory

    I’m pretty sure that I already have zsh downloaded. Can you help me figure out this error?

  2. Hi Umair!

    I installed codeblocks and I’m trying to run an int code but it’s not working. This is the error:

    /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/mirzashuja/Desktop/assignment icp/bin/Debug/assignment icp
    ➜ ~ /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/mirzashuja/Desktop/assignment icp/bin/Debug/assignment icp
    sh: /Users/mirzashuja/Desktop/assignment: No such file or directory

    I checked if I have the zsh file and I already have it installed. Can you help me?
    Thank you!

    1. Most of the errors I have seen that are about missing files or directories are usually when the compiler isnt installed in the required path. Check the path here: Settings->Compiler->Toolchain executables->Compiler installation directory it should be in a directory called minGW

  3. Hello
    i’ve installed Xcode and code blocks but i have already problem in running
    the error code is this

    login: Sat Mar 6 19:24:21 on ttys001
    [email protected] ~ % ‘/Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/nattyeilueye/Desktop/new/bin/Debug/new ‘
    zsh: no such file or directory: /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/nattyeilueye/Desktop/new/bin/Debug/new
    [email protected] ~ %

  4. HI, I’m so sorry if you’ve already answered this. I am trying to learn C++, and when I tried to open and run the “hello world” program, this is the error I am getting :
    ‘/Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Kayleigh/Desktop/c++projects/giraffe_tutorial/bin/Debug/giraffe_tutorial ‘
    -bash: /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Kayleigh/Desktop/c++projects/giraffe_tutorial/bin/Debug/giraffe_tutorial : No such file or directory

    I saw in an earlier reply that you said to change the default shell, but I’m not entirely sure what that means. Thank you!

    1. No worries! Let’s try this. Open up your command line terminal and enter this sudo sh -c "$(curl -fsSL"
      . If it prompts for your password, enter it. This will install zsh. Next, you need to enter this chsh -s /bin/zsh. Then try restarting your PC (might not be necessary) and try running your program again! Good luck!

  5. Hi Umair,
    I followed all the steps and everything works fine, but when I run it, I get this on my Terminal:

    Last login: Thu Aug 27 18:34:04 on ttys000
    [email protected] ~ % ‘/Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/janiceliman/Documents/comsci/try/bin/Debug/try ‘
    zsh: no such file or directory: /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/janiceliman/Documents/comsci/try/bin/Debug/try
    [email protected] ~ %

    can you help me with this?

  6. Hi Umair,
    i followed the steps and its working fine. I have one problem. I’m a newbie to coding. when i copy a code to code blocks, there’s a fatal error saying Softwareserial.h file not found. i already include it in the code and dont know what to do next. Can you advice please?

  7. Hello Umair,
    I have followed your steps but everytime i run the project i get this on my Terminal:Last login: Fri Apr 17 18:01:03 on ttys000

    The default interactive shell is now zsh.
    To update your account to use zsh, please run `chsh -s /bin/zsh`.
    For more details, please visit
    192-168-0-111:~ sarascintei$ ‘/Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/sarascintei/Desktop/info/incerc/pb1/bin/Debug/pb1 ‘
    -bash: /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/sarascintei/Desktop/info/incerc/pb1/bin/Debug/pb1 : No such file or directory
    192-168-0-111:~ sarascintei$

    and also when i type int,cin,cout… it appears an empty grey box on the screen and stays there until i close codeblocks

    Thank you!

    1. I think this is just a compiler issue. Codeblocks is not able to access the compiler. Did you try changing the default shell from sh or bash to zsh as the message suggested? Can you try that and see if it works?

  8. Hello Umair,

    I have installed CodeBlocks on my Mac Book Pro (2011) and it runs great. But if I want to use the Debugger I get this Error:

    ERROR: You need to specify a debugger program in the debuggers’s settings.
    (For GCC compilers, it’s ‘gdb’ (without the quotes))

    I have downloaded Xcode now but i don’t have a clue what I have to change in the settings that it works.
    Do you know a solution?

    Thanks a lot.

    1. Please go to Settings > Compiler > Global compiler settings > Toolchain executables you’ll find a dropdown for the debugger section. It should say gdb-debugger (default). Please check that and let me know if it works for you. The gdb should be in the same folder where the rest of your gcc toolchain is installed. If you are unable to locate gdb in your gcc toolchain folder then select the appropriate folder where it is located. I hope that helped. Let me know if it didn’t.

  9. Hello Umair!
    I have downloaded CodeBlock and did what you said but I get this when I run the first program: Can’t create output directory bin/Debug.
    Please help me and tell me what to do now?

  10. Hi Umair,
    I have everything for CodeBlock Downloaded but the programs wont run properly as my Complier Installation Directory is reading /usr and thats all. I don’t know how to change it so that it works.

    1. Go to project build options -> search directories -> compiler and add the path to your library over here. Let me know if that works.

        1. I am sorry I missed an arrow there, go to Project -> Build options. If that is greyed out for you, then please make sure that you are saving the file with the right extension. That would most probably be .c or .cpp. I hope that helps, please let me know if you have any other queries.

  11. 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.

  12. 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.

  13. 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\ 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 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.

  14. 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?

      1. Hello
        i’ve installed Xcode and code blocks but i have already problem in running
        i got this in terminalLast login: Sun Dec 13 15:22:45 on ttys000
        apples-MacBook-Pro:~ Apple$ /Applications/ DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Apple 1/Documents/c++/uni1-/bin/Debug/uni1-
        sh: /Users/Apple: is a directory

        Process returned 126 (0x7E) execution time : 0.004 s
        Press ENTER to continue.
        and when press enter i got thisapples-MacBook-Pro:~ Apple$
        i don’t know what to do plz help me
        my mac version is 10.12.6

        1. I think there’s something wrong with the path that you have. It’s got whitespaces in it. Please check the path of the directory and fix it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.