Install CodeBlocks 17.12 on macOS Mojave or newer
Update 05. September 2019: There is an easier solution which includes an already pre packaged mac port of the latest Code::Blocks version. You can download it directly from the Code::Blocks developers using this link: https://sourceforge.net/projects/codeblocks/files/Binaries/17.12/
(Thank you @__name__ for spotting the link)
When using the below mentioned method make sure to run the commands as sudo if you are getting insufficient privileges error !
Due to lack of active developers by the Code::Blocks team there is currently no native Code::Blocks version available for the macOS platform which is newer than v13.12 (Published 2013).
Since it is still a popular C/C++ IDE I thought it would be interesting to share a way in which you can get the latest version running through a Linux port. The port runs fairly stable and much better than the currently available native version.
In order to get Code::Blocks 17.12 running on your mac we will need the following prerequisites which we will install step by step:
- XCode Developer Tools
- XQuartz
- MacPorts
- CodeBlocks using MacPorts
We will be using the macOS command line through the whole process so I would recommend to leave it open until we are finished. You can find the mac terminal by invoking the spotlight search (CMD ⌘ + Spacebar) and searching for Terminal.
- Installing XCode Developer Tools
Input the following line into the Terminal window:
xcode-select — install
The following window should now show up in which you just have to accept the installation prompt by clicking “install”. If you get the message that the developer tools are already installed you can proceed with the next step.
After the installation type in the following command to accept the XCode license agreement.
xcodebuild -license
- Installing XQuartz
Please proceed to the XQuartz website (https://www.xquartz.org/) where you can get the latest version of XQuartz by downloading the provided .dmg file.
Open the .dmg file on your mac and follow the installation procedure from the given .pkg installer.
Once you have finished the installation you will need to log out and log in again to activate the XQuartz window manager. XQuartz is needed for the Code::Blocks app since it is the main window manager without it Code::Blocks won’t start !
- Installing MacPorts
Download the .pkg file for your macOS version from the official MacPorts website (https://www.macports.org/install.php).
You can check what mac version you currently have by clicking the Apple icon on the top left corner and selecting “About This Mac”. Your macOS version name will be written in bold at the top of the pop up window.
On the MacPorts website (https://www.macports.org/install.php) you will find the corresponding .pkg installer to your macOS version (In my case this would be macOS Mojave)
Follow the installation instructions of the .pkg installer.
- Installing Code::Blocks using MacPorts
We will now have to return to the terminal and use MacPorts (Which is a terminal tool) to install the Linux port of Code::Blocks 17.12 on our Mac.
Type the following command into your terminal which will install Code::Blocks and all its needed dependencies:
port install codeblocks
WARNING: Do not worry this process will take some time and building Code::Blocks can take up to 15–30 minutes depending on your machine but it will finish eventually just let it run in the background until it is completely finished.
- Running Code::Blocks
When your installation succeeded you can run Code::Blocks by either going into your Applications folder (There will be a MacPorts folder with Code::Blocks inside it) or you can just type in “codeblocks” in the terminal (Without the quotes) and it will run the Linux port.
