Other development environments¶
The previous pages describe the development environments recommended for this course. However, you are not limited to those options.
You can use other online tools, IDEs or C compilers if you prefer. The following alternatives may be useful depending on your operating system and how you want to work.
Note: Some of these options are suitable for the C programming exercises in Module 1 but cannot be used for programming the embedded device in Module 2.
Other online tools¶
Online tools are useful if you want to write and run C programs without installing software on your computer.
In addition to OnlineGDB, you can use:
- Visual Studio Code online. Use similar extensions to the Visual Studio Code desktop application, although some functionality is limited in the browser.
- Replit. Requires registration and may have limitations on the number of projects available with a free account.
- OneCompiler. Simple online C compiler. Does not include a debugger.
- Compiler Explorer. Particularly useful for inspecting the assembly code generated by different compilers. It does not provide a full debugging environment.
Online environments are convenient for small exercises, but they are generally not suitable for Module 2.
Other IDEs¶
You can also use other integrated development environments (IDEs) for C programming.
Some alternatives include:
- Code::Blocks. Easy to install and use.
- Dev-C++
- CodeLite
- Eclipse CDT
These environments usually combine a source-code editor, compiler integration and debugging tools in one interface.
Some IDEs include a compiler, while others require you to install one separately.
C compilers¶
You can also install a C compiler and use it directly from the command line or together with your preferred editor or IDE.
The compiler mainly used in this course is
gcc.Windows¶
On Windows, there are several ways to install
gcc. Two alternatives described in the course material are:- installing MSYS2 and the MinGW-w64 toolchain
- installing MinGW-w64 separately
Installing MSYS2 and MinGW-w64¶
This option installs the MSYS2 environment and the MinGW-w64 development tools.
- Download the latest installer from the MSYS2 page.
- Run the installer and follow the installation wizard. You can install it in any folder on your computer.
- Open the MSYS2 terminal and update the packages:
pacman -Syu
- Open the MSYS2 UCRT64 shell and install the development tools:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
- Check the installation from the MSYS2 UCRT64 shell:
gcc --version
You should now see the GCC version information.
If you want to use
gcc from other programs, such as PowerShell or VS Code, add the compiler directory to the Windows PATH.- Open System Properties > Environment Variables.
- Edit the
PATHvariable for your user or system. - Add:
{{{ <path to MSYS2 installation>\ucrt64\bin
For a default installation, this is typically:
C:\msys64\ucrt64\bin
- Open a new CMD or PowerShell window and check the installation:
gcc --version
For the recommended VS Code setup, see Setting up Visual Studio Code.
Installing MinGW-w64 separately¶
You can also install MinGW-w64 without installing the complete MSYS2 environment.
- Download MinGW-w64 from SourceForge.
- During installation, select x86_64 as the architecture. Select
i686only if you specifically need a 32-bit toolchain. - Follow the remaining installation steps.
- After MinGW-w64 has been installed, navigate to its installation directory and run:
mingw-w64.bat
This configures the environment required to use the compiler.
- Open a command prompt and check the installation:
gcc --version
You should now see the GCC version information.
MinGW-w64 provides the compiler toolchain. You may also want to use it together with a development environment such as:
- Visual Studio Code
- Dev-C++
- CodeLite
- Eclipse CDT
Linux¶
Linux distributions normally provide
gcc through their package manager.Debian / Ubuntu:
sudo apt-get install gcc
If you want the standard development toolchain, install:
sudo apt-get install build-essential
RHEL / Fedora / CentOS:
Use the distribution package manager, such as
yum.Gentoo:
Use
emerge.Arch Linux:
Use
pacman.After installation, check that
gcc is available:gcc --version
You can use
gcc directly from a terminal or together with an IDE such as Code::Blocks.macOS¶
There are several alternatives for C programming on macOS.
Option 1: IDE¶
Use a multiplatform IDE such as Code::Blocks.
Option 2: Xcode¶
Install Xcode.
You may need an Apple account.
Option 3: Homebrew¶
Install Homebrew following the instructions on its website.
Then open a terminal and install GCC:
brew install gcc
Check the installation with:
gcc --version