📑 Quick Navigation
✅Requirements
Before you start, make sure you have the following:
🔍Check Your System
🔎 Identify Your macOS Version & CPU Type
Open your Terminal and run this command:
uname -m
- Shows your macOS version
- Shows your CPU type (arm64 or x86_64)
🔎 Check If C is Already Installed
Run these commands to check:
gcc --version
clang --version
❌ Common Issues
➡️ Solution: Your Terminal may not be opened correctly. Try opening a new Terminal window and try again.
🛠️Install Xcode Tools (C/C++ Compiler)
This installs the C/C++ compiler and build tools you need.
xcode-select --install
- Installs GCC/Clang compilers
- Installs essential build tools
✔️ Verify Installation
After installation completes, run:
gcc --version
clang --version
❌ Common Errors & Solutions
Solution: Run this command:
sudo xcode-select --reset
Then try the installation again.
Solution: Simply run the command again:
xcode-select --install
Sometimes it takes a moment for the popup to appear.
🍺Install Homebrew
Homebrew is a package manager that makes installing software on macOS easy!
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
📍 Add Homebrew to PATH (Important!)
After installation, you need to add Homebrew to your system PATH. Choose the command based on your Mac type:
🔧 For Apple Silicon (M1/M2/M3):
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
🔧 For Intel Mac:
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
✔️ Verify Homebrew Installation
brew --version
❌ Common Errors & Solutions
Problem: Your PATH is not set correctly.
Solution: Re-run the PATH setup command for your Mac type (see above).
Solution: Run this command to fix permissions:
sudo chown -R $(whoami) /usr/local
💻Install Visual Studio Code
VS Code is a powerful code editor perfect for writing C/C++ programs.
brew install --cask visual-studio-code
🚀 Launch VS Code
After installation, you can open VS Code from Terminal:
code
❌ If "code" command is not found:
Follow these steps:
- Open VS Code manually from your Applications folder
- Press Cmd + Shift + P
- Type: Shell Command
- Select: Install 'code' command in PATH
❌ Common Error: "App cannot be opened"
If you see a security warning:
- Go to System Settings
- Navigate to Security & Privacy
- Click Allow for Visual Studio Code
🧩 Install Essential Extensions
Now you need to install two important extensions for C/C++ development:
- Open VS Code
- Click the Extensions icon in the left sidebar (looks like 4 squares)
- Search for and install:
- Prettier - Code formatter (makes your code look nice)
- C/C++ - Official extension (white and purple icon)
✏️Create Test C Program (Optional)
Let's create a simple "Hello, World!" program to test everything works:
📁 Create a Project Folder
mkdir ~/c_projects
cd ~/c_projects
touch hello.c
✍️ Edit hello.c
Open the file in VS Code and add this code:
#include <stdio.h>
int main() {
printf("Hello, World!\\n");
return 0;
}
🔨 Compile & Run
gcc hello.c -o hello
./hello
Hello, World!
🖥️Install QEMU
QEMU is a virtual machine emulator that lets you run Linux on your Mac.
brew install qemu
✔️ Verify QEMU Installation
qemu-system-x86_64 --version
qemu-system-aarch64 --version
❌ Common Errors & Solutions
Don't worry! This is normal and can be safely ignored. QEMU will still work fine.
This is normal on macOS! macOS doesn't support KVM (Kernel Virtual Machine). QEMU will use HVF (Hypervisor Framework) instead, which is actually better on Apple Silicon Macs.
⚙️Setting Up QEMU (Linux VM)
🔍 Check Your Mac Type
First, determine if you have Apple Silicon or Intel:
uname -a
- If you see arm64 → You have Apple Silicon (M1/M2/M3)
- Otherwise → You have an Intel Mac
📥 Download Ubuntu VM Image
Choose the download link based on your Mac type:
Click this link to download:
https://bham-my.sharepoint.com/personal/e_ritter_bham_ac_uk/_layouts/15/guestaccess.aspx?share=IQDChBPtZAjQRq6qrRZ4jHY9AVlZLe5TuHMfy-36VqJ8heg&e=13QF9O
Click this link to download:
https://bham-my.sharepoint.com/personal/e_ritter_bham_ac_uk/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fe%5Fritter%5Fbham%5Fac%5Fuk%2FDocuments%2FShared%2FOS%5FSP%2F2025%5F26%2Fubuntu24%2E04%2Eqcow2%2Ezip&parent=%2Fpersonal%2Fe%5Fritter%5Fbham%5Fac%5Fuk%2FDocuments%2FShared%2FOS%5FSP%2F2025%5F26&ga=1
📂 Organize Your Files
Navigate to your Downloads folder and organize the files:
cd ~/Downloads
mkdir vm-image
# Move the downloaded file to the vm-image folder
mv ubuntu24.04-arm64.qcow2 vm-image
cd vm-image
ls
📥 Download Startup Scripts
Download the startup file from this link:
https://bham-my.sharepoint.com/personal/e_ritter_bham_ac_uk/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fe%5Fritter%5Fbham%5Fac%5Fuk%2FDocuments%2FShared%2FOS%5FSP%2F2025%5F26%2Fubuntu24%2E04%2Darm64%2Eqcow2%2Ezip&parent=%2Fpersonal%2Fe%5Fritter%5Fbham%5Fac%5Fuk%2FDocuments%2FShared%2FOS%5FSP%2F2025%5F26&ga=1
📦 Extract Startup Scripts
Extract the startup scripts into your vm-image folder:
cd ~/Downloads/vm-image
unzip ~/Downloads/startupVM.zip
ls
- sysprog-start-linux
- sysprog-start-mac
- sysprog-start-mac-arm64
- ubuntu24.04-arm64.qcow2
- ...and more
🔐 Make Scripts Executable (Important!)
Before running the scripts, give them permission:
chmod +x sysprog-start-*
🚀 Start the Virtual Machine
Choose the command based on your operating system:
./sysprog-start-linux
./sysprog-start-mac-arm64
./sysprog-start-mac
⏳ Wait for the VM to Boot
After running the startup script:
- A new QEMU window will open 🖥️
- Ubuntu will start booting
- This takes 1–2 minutes the first time
- When ready, you'll see a login prompt
🔑 Login to the VM
Use these credentials:
Password: bham
✔️ Test That It Works
After logging in, run these commands:
ls
cd helloWorldExample
make
./helloWorld
Hello World
The value of i is 0
🌐 Optional: Connect via SSH
Instead of using the VM window, you can access it from your laptop's terminal:
ssh bham@10.187.0.2
Password: bham
📤 Copy Files Between Laptop & VM
📥 From Laptop → VM:
scp myfile.c bham@10.187.0.2:/home/bham/
📤 From VM → Laptop:
scp bham@10.187.0.2:/home/bham/output.txt .
⚠️Common Problems & Fixes
Solution: Make sure your startup scripts are executable:
chmod +x sysprog-start-*
Problem: You might be in the wrong directory.
Solution: Check your current location:
ls
You must see the sysprog-start-* files in your directory.
Problem: QEMU might not be installed.
Solution: Install QEMU for your system:
brew install qemu
Problem: macOS doesn't support KVM (Kernel Virtual Machine).
Solution: Use HVF (Hypervisor Framework) instead:
qemu-system-x86_64 -accel hvf -m 4G
Solution: Set the compiler path in VS Code:
- Press Cmd + Shift + P
- Type: C/C++: Edit Configurations
- Set the compilerPath to your GCC or Clang location
🎉 You're All Set!
Congratulations! 🎊 You've successfully set up your development environment with QEMU, C/C++, VS Code, and Homebrew on macOS. You're now ready to start programming and running Linux virtual machines!
Happy coding! 💻✨