C Development Environment Setup Tutorial

In this C tutorial we learn how to set up a development environment with CodeBlocks on a Windows, Mac or Linux system to develop C applications.

Here's a table of contents of what you'll learn in this lesson:
(click on a link to skip to its section)

Let's jump right in.

CodeBlocks IDE for this course

In this tutorial series we’ll be using an application called CodeBlocks as our integrated development environment. Codeblocks makes it easy to get setup and start learning how to write programs in C.

If you don’t want to use Codeblocks, you can see our list of alternative IDE’s for programming in C further down below.

Codeblocks is a free, cross-platform, IDE for C, C++ and Fortran. Codeblocks will run on Windows, as well as any Unix-based operating system like Linux or Mac.

It was designed to be as extensible and configurable as possible, and any kind of functionality can be added to it by installing a plugin. In fact, Codeblocks uses plugins to add compiling and debugging functionality.

Highlights:

  • It’s open source with a GPLv3 licence.
  • It’s cross-platform (Windows, Linux, Mac OSx).
  • It’s written in C++.
  • It can be extended through freely available plugins.

Codeblocks also supports multiple popular compilers.

  • Compilers:
    • GCC (MingW / GNU GCC)
    • MSVC++
    • clang
    • Digital Mars
    • Borland C++ 5.5
    • Open Watcom
    • etc.
  • It has a fast custom build system and no makefiles are needed.
  • It has support for parallel buils by utilizing a CPU’s extra cores.
  • Workspaces can combine multiple projects.
  • Inter-project dependencies can be seen inside a workspace.
  • etc.

Codeblocks supports both the GNU GDB and MS CDB debuggers, although the MS CDB is not fully featured.

Debuggers:

  • Supports GNU GDBOpens up in a new page
  • Also supports MS CDB (although not fully featured).
  • Full breakpoints support:
    • Code breakpoints.
    • Data breakpoints (read, write and read/write).
    • Breakpoint conditions (break only when an expression is true).
    • Breakpoint ignore counts (break only after certain number of hits).
  • Display local function symbols and arguments.
  • User-defined watches (support for watching user-defined types through scripting).
  • Call stack.
  • Disassembly.
  • Custom memory dump.
  • Switch between threads.
  • View CPU registers.

Although a bit bland, the Codeblocks interface has everything we expect from a professional IDE.

Interface:

  • Syntax highlighting that is also customizable and extensible through plugins.
  • Code folding for C, C++, Fortran, XML and more.
  • Tabbed interface to keep our workspace organized.
  • Code completion for C, C++, Fortran etc.
  • A Class browser.
  • Smart indentations.
  • To-do list management that supports different users.
  • And many more features through plugins.

How to download and set up CodeBlocks on Windows

Please follow the steps below to download and install Codeblocks on Windows.

  1. Go directly to the SourceForge download pageOpens up in a new page for Codeblocks with a bundled compiler. The download should start automatically.
  2. Run the Codeblocks setup file and follow the installation instructions. The default settings will be fine so you can select Next > I agree > Next > Install.

That’s it. You can skip directly to the section on how to set up a project in Codeblocks below.

How to download and set up CodeBlocks on Mac OSX

Please follow the steps below to download and install Codeblocks on Mac OSx.

  1. Go directly to the SourceForge download pageOpens up in a new page . The download should start automatically.
  2. If you don’t have Xcode installed on your system, download the Developer ToolsOpens up in a new page from Apple as well.
  3. Open the disc image (.dmg file) and drag it into your Applications folder.

There is a known bug with the Mac version of Codeblocks where the Keybinder plugin may not work. For safety, you can simply disable it.

That’s it. You can skip directly to the section on how to set up a project in Codeblocks below.

How to set up a project in CodeBlocks

Please follow the steps below the set up a new project in Codeblocks.

  1. Start Codeblocks (if it’s not already running).
  2. Go to File > New > Project.
  3. In the pop-up dialog box, choose Console Application and click Go.
  4. Click Next on the first page of the wizard.
  5. Choose C as the language and click Next.
  6. Name the project “LearningC”. Specify a path to save your programs, we chose C:\KHQC. Click Next.
  7. The GNU GCC compiler should already be selected so click Finish.

Codeblocks will set up an empty project for us. Our application’s source code will live in this project.

You can skip directly to the next tutorial lesson on how to create your first C program .

List of alternative IDE’s

The list below shows our personal preference for IDE’s on whichever platform you use. These IDE’s come in both free and premium (commercial) versions.

The list below shows other IDE’s either built specifically for C, or that have C compatibility via plugins, packages, addons etc.

Eclipse
Cross-platform | Free

CodeLite
Cross-platform | Free

Visual Studio Code
Cross-platform | Free

Atom
Cross-platform | Free

Netbeans
Cross-platform | Free

KDevelop
Cross-platform | Free

Sublime Text
Cross-platform | Free & Commercial

Jetbrains CLion
Cross-platform | Commercial