Install gcc-15.1 form source in Ubuntu (chatGpt reply)

✅ 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

bash
sudo 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

bash
cd ~/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

bash
mkdir ../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)

bash
make -j$(nproc)

6. Install

bash
sudo make install

7. Use GCC 15.1

Add it to your shell:

bash
echo '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

bash
gcc --version

Should show:

scss
gcc (GCC) 15.1.0

✅ Optional: Set it system-wide (alternative)

Update update-alternatives if you want it globally:

bash
sudo 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:

bash
sudo update-alternatives --config gcc sudo update-alternatives --config g++

No comments:

Post a Comment

If you have any doubts, please let me know.

Regarding site Free Browser Tool (https://free-browser-tools.mohitkrgupta.dev) (discussion with google search AI)

Various discussions with Google Search AI regarding site  Free Browser Tool are as below: site free-browser-tools.mohitkrgupta.dev what doe...