Install Ubuntu 20.04 Compiler Edition
Complete guide for setting up Ubuntu 20.04 as a dedicated compilation and development environment. This "Compiler Edition" includes all necessary tools for building software from source code.
System Requirements
Compiling is a resource-intensive task! Choose the appropriate setup based on your needs:
Minimal Setup
- Storage: 30 GB SSD
- Memory: 2 GB RAM
- CPU: 2 cores
- Usage: Small projects, learning, testing
Good Setup (Recommended for most users)
- Storage: 120 GB SSD
- Memory: 4 GB RAM
- CPU: 4 cores
- Usage: Medium projects, web browsers, applications
Better Setup
- Storage: 1 TB SSD + 2 TB HDD
- Memory: 16 GB RAM
- CPU: 8 cores
- Usage: Large projects, Chromium, Linux kernel
Best Setup (Professional)
- Storage: 3 TB SSD + 10 TB HDD
- Memory: 64 GB RAM
- CPU: 24 cores
- Usage: Multiple large projects simultaneously, enterprise development
Step 1: Install Ubuntu 20.04
Download Ubuntu 20.04
Download Ubuntu 20.04.6 LTS from ubuntu.com
Installation Options
For Virtual Machine:
- VMware Workstation
- VirtualBox
- Hyper-V
- Proxmox
For Physical Machine:
- Create bootable USB with Rufus (Windows) or dd (Linux)
- Boot from USB and follow installer
Installation Type
Choose Minimal Installation to reduce bloat:
- Unchecks web browsers, games, media players
- Keeps only essential system utilities
- Faster installation and updates
Step 2: Initial System Update
After installation, update the system:
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
Step 3: Enable Source Code Repositories
Via GUI
- Open Software & Updates
- Go to Ubuntu Software tab
- Check ✓ Source code
- Go to Updates tab
- Ensure all update types are enabled
- Click Close and Reload
Via Command Line
sudo sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list
sudo apt update
Step 4: Install Essential Build Tools
Build Essentials Package
This includes GCC, G++, Make, and other core compilation tools:
sudo apt install -y build-essential
Verify installation:
gcc --version
g++ --version
make --version
Additional Development Tools
sudo apt install -y git curl wget vim nano htop
Step 5: Install Compiler Toolchains
GCC/G++ (Multiple Versions)
Install different GCC versions for compatibility:
sudo apt install -y gcc-7 g++-7 gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10
Set default version:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
Clang/LLVM
sudo apt install -y clang llvm lld
Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
Go
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install -y golang-go
Node.js and npm
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
Step 6: Install Build Dependencies
CMake and Ninja
Modern build systems:
sudo apt install -y cmake ninja-build
Autotools
For older projects:
sudo apt install -y autoconf automake libtool
Package Config
sudo apt install -y pkg-config
Step 7: Install Common Libraries
Development Libraries
sudo apt install -y \
libssl-dev \
libcurl4-openssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
libgdbm-dev \
libnss3-dev \
libedit-dev
Graphics Libraries (for GUI applications)
sudo apt install -y \
libx11-dev \
libxext-dev \
libxrender-dev \
libxrandr-dev \
libxinerama-dev \
libxi-dev \
libxcursor-dev \
libgl1-mesa-dev \
libglu1-mesa-dev
Audio Libraries
sudo apt install -y libasound2-dev libpulse-dev
Step 8: Install Version Control
Git Configuration
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --global init.defaultBranch main
Subversion (SVN)
For older projects:
sudo apt install -y subversion
Step 9: Install Python Development Tools
sudo apt install -y python3-pip python3-dev python3-venv
pip3 install --upgrade pip setuptools wheel
Step 10: Optimize for Compilation
Increase Swap (for low-memory systems)
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Adjust Build Parallelism
Add to ~/.bashrc:
# Use all CPU cores for compilation
export MAKEFLAGS="-j$(nproc)"
Apply changes:
source ~/.bashrc
Step 11: Install IDE/Text Editors (Optional)
Visual Studio Code
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt update
sudo apt install -y code
Vim with plugins
sudo apt install -y vim-gtk3
Verification
Test your compiler setup:
C Program Test
Create hello.c:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Compile and run:
gcc hello.c -o hello
./hello
C++ Program Test
Create hello.cpp:
#include <iostream>
int main() {
std::cout << "Hello, C++!" << std::endl;
return 0;
}
Compile and run:
g++ hello.cpp -o hello_cpp
./hello_cpp
Maintenance
Keep System Updated
sudo apt update && sudo apt upgrade -y
sudo apt autoremove -y
sudo apt autoclean
Monitor Compilation Resources
htop # Press F10 to exit
Next Steps
- See "How to compile" manual for detailed compilation guides
- Check "Install ALL compiler dependencies" for project-specific requirements
- Review "Compile Chrome in Linux" for advanced compilation example
Troubleshooting
Out of Disk Space
Check usage:
df -h
Clean package cache:
sudo apt clean
Out of Memory During Compilation
Reduce parallel jobs:
export MAKEFLAGS="-j2" # Use only 2 cores
Missing Dependencies
Check build logs and install missing packages:
sudo apt install <package-name>-dev