✅ Step-by-step: Build and Install GCC 15.1 on Ubuntu
⚠️ Estimated time: ~30–60 mins
✅ Works on Ubuntu 20.04 / 22.04 / 24.04
1. Install dependencies
bashsudo apt update
sudo apt install -y build-essential wget curl git \
libgmp-dev libmpfr-dev libmpc-dev libisl-dev \
flex bison libzstd-dev
2. Download GCC 15.1 source
bashcd ~/Downloads
wget https://ftp.gnu.org/gnu/gcc/gcc-15.1.0/gcc-15.1.0.tar.xz
tar -xf gcc-15.1.0.tar.xz
cd gcc-15.1.0
./contrib/download_prerequisites
This will fetch GMP, MPFR, MPC, and ISL into the source tree.
3. Create build directory
bashmkdir ../gcc-15.1-build
cd ../gcc-15.1-build
4. Configure build
bash../gcc-15.1.0/configure \
--prefix=/opt/gcc-15.1 \
--disable-multilib \
--enable-languages=c,c++,fortran \
--enable-bootstrap \
--enable-checking=release
5. Build (takes time)
bashmake -j$(nproc)
6. Install
bashsudo make install
7. Use GCC 15.1
Add it to your shell:
bashecho 'export PATH=/opt/gcc-15.1/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/opt/gcc-15.1/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
8. Check version
bashgcc --version
Should show:
scssgcc (GCC) 15.1.0
✅ Optional: Set it system-wide (alternative)
Update update-alternatives if you want it globally:
bashsudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-15.1/bin/gcc 1501
sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-15.1/bin/g++ 1501
Then run:
bashsudo update-alternatives --config gcc
sudo update-alternatives --config g++
No comments:
Post a Comment
If you have any doubts, please let me know.