Getting Started on macOS or Linux with Code::Blocks IDE
Start course

This course will help you prepare for the Complete C++ Developer learning path and get you set up with the right development environments.

Learning Objectives

  • Set up Visual Studio, VS Code, or Code::Blocks depending on whether you'll be working on Windows, Mac, or Linux as you follow along with the exercises in this course

Intended Audience

  • Beginner coders, new to C++
  • Developers looking to upskill by adding C++ to their CV
  • College students and anyone studying C++


This is a beginner-level course and so no prior knowledge of C++ is necessary.


If you're working on a Mac or Linux computer, then I recommend Code::Blocks as the IDE. There is also a Windows version as well. So, you can use this if you prefer it over Visual Studio. There are certainly other options. For example, if you already do development on Mac, you might like XCode and you're perfectly welcome to continue using that. Another popular choice for development on both Linux and MacOS is called Visual Studio Code. This shouldn't be confused with Visual Studio IDE. It is a different piece of software altogether. But with Visual Studio Code you could create and write programs with C++ on any platform. Visual Studio IDE is available for MacOS but it doesn't officially support C++ so I don't recommend it. So, as mentioned, let's look at how we can get Code::Blocks IDE for C++ development. First, we have to download it. You'll notice that I have already done a search here and then I have Code::Blocks IDE as one of the search options at the top. I will click this and it takes me to the Code::Blocks website. So, we can go to downloads and then under downloads, you'll notice that there are binary releases and this is exactly what you want. You don't want the source code for it because you're not developing Code::Blocks itself and you're not retrieving the source code from an SVN. So, right here download the binary release. If I click that you'll notice that there's a list of different releases for Windows and there's also some versions down near the bottom for Linux and also at the very bottom there's Mac. So, I'm going to download the Mac version. You can get it from either Sourceforge or FossHub right there. I'm going to click on Sourceforge and you will notice that after you give it a second, it will download the zip file and I'm going to click the little arrow and go to show in Finder and there it is right there. I can close the browser window now because I do not need it. Now, I'm just going to see what's in here. I can actually double click it and that will unzip it and right out of the box, basically there is the executable with everything it needs, the application. So, I'm going to drag this onto the desktop. You can put it in applications, you can put it in your documents wherever you like it and that's fine. And you can get rid of the zip when you're done if you want. You'll notice also that I have made a CPP working directory and that's just a plain old folder. If I double click it, it's just an empty folder as you can see and projects will be different in Code::Blocks than what you will see me doing with Visual Studio throughout the course on Windows. Visual Studio IDE usually has a top level folder for a so-called solution and then inside the solution, you have one or more projects and those each get their own folders as well. It also creates other sub folders for source files, compiled object files, and other stuff. Code::Blocks doesn't require this top level solution folder and in some ways is even easier to use than Visual Studio. So, what we're going to do is we're going to create an empty project. So, I'm going to double click Code::Blocks right here and it will say it's an application downloaded from the Internet, are you sure this is just a security feature because we didn't install it through the Apple Store or anything like that? So, it doesn't know about the security and it wants to make sure we're confident with it. So, I'm going to hit 'Open' and here you go when you first launch it, it asks you what compiler you want to use? It detects compilers. So, right here we have the GNU GCC Compiler detected. If you don't have the GNU GCC compiler or Clang or another compiler already installed here, then you'll need to download this and install it as well. So, you can do a search for it, look for the Mac version and install it just like pretty much any other application. So, this is already on this machine. So, I'm going to accept that compiler. And our compiler is going to be part of the IDE essentially or used by the IDE. Alright, so Code::Blocks has opened and we have a workspace over here which is empty. I'm going to go now and create an empty project that we've been waiting for, make sure it's Code::Blocks, File, New and then project, okay? We're going to create a full project. And in here we have many, many, many different options here for different types of applications. You could change the category if you wanted to and just maybe changing the console and that'll narrow it down for us, and I'm going to create an empty project. Now, if we created a console application, it would actually give us starter code and a main file as well, but I'm going to show you how to do it from scratch, completely from scratch. So, hit 'Go' on empty project and it'll start the wizard. Here, you hit 'Next'. Give it a project title. So, we'll call this, we'll say my-mac-test-1 and it will ask you where you want to create the project folder. I'm going to click the little button off to the side here and it will let me choose where to put this. Now, if I go to the desktop, remember that little folder I created, cpp-workdir? That's where I want to save my projects. So, I will click 'Choose' and it chooses that folder and it will make a subfolder for just my project, and it also creates a project file name with Code::Blocks, preferences and different options listed in here, the Code::Blocks can understand. I'm now going to hit 'Next' and it asks which compiler you want to use and that's the one we selected by default. You could choose other ones if you have them available, but GNU GCC compiler is one of the more popular ones. So, we'll use that one, we can keep the debug and release, it doesn't really matter. We could uncheck release for now, but doesn't really matter. We'll hit 'Finish'. So, you'll see that there's a project folder or project right under the workspace, and what we want to do is add a file to this. So, I'm just going to go to File, New and then just select empty file. So, the empty file will be created here. It will say, do we want to add this file to the project or you just created a file and you're going to say, yes, we're adding it to the project. It'll ask you what its name is and we're going to put main.cpp. So, in Visual Studio which I'll be demonstrating pretty much the entire course in, if you see me create a file, main.cpp, this is what you do. File, New, empty file and then call it main.cpp added to the project. I will hit 'Save' now and unless we want to have the targets set as debug and release, I'll say, OK. And right here, inside of this is a sources folder and then we have main.cpp. I'm going to control and then scroll a little bit so you can see this editor bigger and it's totally okay if you don't understand what I'm typing and don't worry about it, because we're going to go over this in the course. The whole point to this is just a test to make sure we have the compiler and the IDE installed properly. So, you're going to include, and then iostream inside angle braces which is a less than sign and a greater than sign, using name space standard, std for standard. int main and then I return zero at the bottom with a semicolon, like the winky-winky at the very end here. It's like the thing you use for a wink face right next to the L on a standard English keyboard. Right, like that, but it's just the semicolon, right? So, now we're going to do cout<<, this is called the stream insertion operator. I'm going to say Hello C++ and then close it with double quote. The double quotes are typically on a standard keyboard to the right of the keyboard next to the Enter key. It's on the same keys, the apostrophe or what we say in programming the single quote. Two less than signs again and then endl and a semicolon. endl stands for end line. It will force the insertion to go to the next line which causes there to be a new line basically. So, this doesn't get crammed up next to the stuff that the IDE or the compiler generates itself. So, this is our whole program. This is a very simple program. We will make something very similar to this in the beginning of the course, you'll know what we're doing and here in Code::Blocks, whether you're on Windows, Linux or Mac, what you need to do. Whenever I go to debug, start without debugging on Visual Studio. Listen carefully here, instead of going to debug, you're going to go to build, unless I'm actually doing a debug, which is way later in the course. Go to build and then you want to go to build and run every time. Build and run. It will launch a terminal window and then it will pop up. So, you notice this little pop up, this stuff is generated by the terminal and different stuff generated by the actual IDE or compiler And then the stuff that our program does is actually right here, see how it says "Hello C++" that's what our code is supposed to do. It says press enter to continue and that's the best way to exit this is to hit 'Enter'. And then you can close the X. And then close the X on this one too if another one pops up and you should be all set. Now, that pretty much wraps up the basic installation and setup. I hope you enjoy the course. I'll see you later.


About the Author
Learning Paths

John has a Ph.D. in Computer Science and is a professional software engineer and consultant, as well as a computer science university professor and department chair.

Covered Topics