Hello Friends,In this tutorial, I will show you how to install and setup code blocks on mac os x Catalina to run C/C program. I have explained the whole pr. MacOS Catalina, the latest version of the world’s most advanced desktop operating system, is now available as a free software update. With macOS Catalina, users are able to enjoy Apple Arcade, a groundbreaking new game subscription service featuring new, exclusive games from some of the world’s most creative developers.
Posted on October 12, 2019 by Paul
Updated 8 May 2020
In this tutorial, I will show you how to compile from source and install the current stable version of GCC on your macOS computer. The instructions from this tutorial were tested on Catalina (macOS 10.15).
Clang, the default compiler for macOS, supports only C, C++, Objective-C and Objective-C++. If you are interested in a modern Fortran compiler, e.g. you will need gfortran that comes with GCC. Another reason to have the latest stable version of GCC on your macOS is that it provides you with an alternative C and C++ compiler. Testing your code with two different compilers is always a good idea.
Building GCC 10 from sources could take some time, in my case it took about two hours on a MacBook Air with a 16GB of RAM.
In order to compile GCC from sources you will need a working C++ compiler. In the remaining of this article I will assume that you have installed the Command Line Tools for Xcode. At the time of this writing Apple’s Command Line Tools maps the gcc and g++ to clang and clang++. If you don’t have the Command Line Tools installed, open a Terminal and write:
which will guide you through the installation process.
Let’s start by creating a working folder:
Next, we can download and extract the latest stable version of GCC:
GCC 10 depends on a couple of other libraries (GSL, GMP, MPFR and ISL) that can be downloaded with:
the above four prerequisites will be built during the GCC build.
We are ready to compile GCC now. Be prepared that this could take some time … Since I’m interested only in the C, C++ and Fortran compilers, this is the configure command I’ve used on my machine:
The above command instructs the configure app to add a prefix to all the resulting executable programs, so for example if you want to invoke GCC 10.1.0 you will write gcc-10.1, the gcc command will invoke Apple’s version of clang.
If you are interested in building more compilers available in the GCC collection modify the –enable-languages configure option.
And now, the final touches:
Grab a coffee, maybe a book, and wait … this should take approximately, depending on your computer configuration, an hour … or more … and about 4.15GB of your disk space for the build folder.
Install the compiled gcc in /usr/local/gcc-10.1.0:
Now, you can keep the new compiler completely isolated from your Apple’s gcc compiler and, when you need to use it, just modify your path by writing in Terminal:
If you want to avoid writing the above command each time you open a Terminal, save the above command in the file .zshrc from your Home folder, e.g:
You should be able to invoke any of the newly built compilers C, C++, Fortran …, invoking g++ is as simple as writing in your Terminal:
Remember to erase the working folder from your HOME if you want to recover some space:
Next, I’ll show you how to check if the compiler was properly installed by compiling and running a few examples. GCC 10 uses by default the C++14 standard and C11 for the C coders, you should be able to compile any valid C++14 code directly. In your favorite text editor, copy and save this test program (I’ll assume you will save the file in your Home directory):
Compiling and running the above lambda example:
We could also compile a C++ code that uses threads:
Next, we present a simple C++ code that uses regular expressions to check if the input read from stdin is a floating point number:
If you are a Fortran programmer, you can use some of the Fortran 2008 features like doconcurrent with gfortran-10.1:
The above code can be compiled with (assuming you’ve saved it as tst_concurrent_do.f90):
If you are interested in learning more about the new C++11/C++14 syntax I would recommend reading The C++ Programming Language by Bjarne Stroustrup.
or, Professional C++ by M. Gregoire, N. A. Solter, S. J. Kleper 2nd edition:
If you need to brush your Fortran knowledge a good book is Modern Fortran Explained by M. Metcalf, J. Reid and M. Cohen:
With the release date of macOS Catalina, 10.15 Xcode 11 beta also released. At the current time to test macOS Catalina on VirtualBox or VMware Workstation. Besides that, if you are a developer to develop any kind of App for macOS or Windows. But the bad news there are different tools for Windows Microsoft to develop any App, but Xcode is not available for Windows. Because of the software which we install on macOS, we can’t install on Windows. Also, most of the developers who develop Apps are interested to use the world number developer tool XCode. Unfortunately, they are a Windows user and the XCode app isn’t exist for Windows. Now worries certainly we taken out the solution to install XCode on Windows. Don’t be frustrated at this point that you can’t install XCode on Windows.
There are multiple ways that you can install XCode on Windows with a platform. To get started you need some effort to access XCode on Windows. As I mentioned for you with the release date of macOS Catalina Apple release XCode 11. Indeed XCode 11 includes interesting features. Like SwiftUI, MiniMap, Rich Documentation, Swift Package Manager, Inline Diff, Transform iPad Apps to Mac, Debugging and Simulators. However, XCode with its significant features is available now in the Mac App Store. If you don’t have a Mac computer to install XCode on that. Then you can install on the guest operating system of macOS on VirtualBox or VMware. Before that, you have to install macOS Catalina on VMware or install macOS Catalina on VirtualBox. Follow the full instruction on how to install XCode on macOS Catalina 10.15 on Windows PC.
XCode 11 latest version includes the following new features
- SwiftUI: This year one of the latest announcements for Xcode 11 is SwiftUI, the best option for creating layout easily with swift codes. However, SwiftUI shows us the real interface of an App. Adding animations and stuff has gone easy with SwiftUI.
- MiniMap: The beautiful look of XCode 11 is on Minimap that appears on the left-handed of the window. It allows the developer to quickly go to the specific part of the coding. This feature is available in some other editor software but newly added to XCode 11.
- Rich Documentation: This part of the feature in XCode 11 looks awesome. Also, the mark hyphen looks better with bolder text. That allows more text to be visible on the screen, it can give a positive effect.
- Swift Package Manager: Waiting is enough, to add the third-party libraries independencies. With the release of XCode 11 introduced a separate built-in manager for XCode. To have this feature go to Swift Packages, Add Swift packages.
- Inline Diff: XCode 11 improved to UI to show changes on each line of code based on version control.
- Transform iPad Apps to Mac: XCode one of the latest and awesome feature is to turn easily iPad Apps fro Mac natively. You can do this by project navigator.
- Debugging and Simulators: Now iOS Simulator is working faster then the previous version of XCode. Metal frameworks can be tested on iOS 13 and tvOS 13. iOS 13 dark theme is a game-changer, during debugging iOS it will automatically turn light mode to dark mode.
What is XCode?
Install macOS Catalina on VMware & VirtualBox
When everything is possible like installing XCode on Windows PC. Also, you installed macOS Catalina on any Virtualization platform then install XCode on it. It is a great chance to install XCode on it. Through this line below you will get the idea on how to install macOS Catalina on VMware Workstation & VirtualBox. However, there are two separate places where you can install macOS Catalina. Whether you want to install macOS Catalina 10.15 on VMware Workstation. Or whether you want to install macOS Catalina on VirtualBox on Windows PC.
There are different virtual machine like VMware Workstation, VirtualBox, Hyper-V. But as I experienced the virtualization installation VMware & VirtualBox is perfect. Both of them are working professionally on Windows PC to run another OS as a guest operating system. The method of installation macOS Catalina on VMware & VirtualBox is the same there aren’t any differences using the VMDK File. But there are separate ways if you use the ISO File of macOS Catalina.
We have done the installation of macOS Catalina perfectly except XCode. On the other hand, you can run multiple Apps of macOS Catalina on a Virtual machine on Windows PC. However, we covered all the files plus installation to make your work easy.
Install XCode on macOS Catalina 10.15 on Windows PC
When you installed macOS Catalina 10.15 on Virtual machine. Then Power on the virtual machine. When you entered the macOS Catalina window click on the Apple Mac App Store. Once the App Store opened on the left-handed search bar type XCode and hit enter.
Once the XCode opened click on Get option
When you clicked on Get, the install button will appear so click on it
Now you will be required to login with your Apple ID to install XCode. Enter your Apple ID and password then click Sign in.
Download Dev C++ For Mac
Wait until macOS Catalina should download XCode, for the downloading you need a nice internet connection. And the size of XCode is 7.81 GB.
Once the downloading finished it will automatically start installing
When the installation completed click Open
Once the XCode launched, you will need to agree with the terms and conditions of it. Click on the Agree button then enter the password and click OK.
Installing the important components of XCode wait until it should complete
Once the components installed successfully, the main window of XCode will open. Now go ahead and start XCode on Windows PC.
That’s it enjoy using XCode on Windows PC by installing macOS Catalina 10.15 on Virtual machines. If you are in trouble of installing macOS Catalina or XCode installation process on Windows PC. Feel free to share your problem below in the comment section. We are happy about listening to your problem in the comment section.