Home > Article > Computer Tutorials > Baidu search: Lan Yiyun [Tutorial on compiling and installing gcc7.3.0 compiler from source code for ubuntu system]
To compile and install the GCC 7.3.0 compiler from source on the Ubuntu system, you can follow the steps below:
Open a terminal and execute the following commands to install the build tools and dependencies:
sudo apt-get update sudo apt-get install build-essential sudo apt-get install bison sudo apt-get install flex
This will install the basic tools and dependencies required to build GCC.
Download the source code of GCC 7.3.0. You can find it on the GCC official website (
) to find the download link for the latest version. Execute the following command in the terminal to download:
wget [GCC下载链接]
Replace [GCC download link]
with the download link for GCC 7.3.0.
Unzip the GCC source code. Execute the following command:
tar xvf [GCC压缩包文件名]
Replace [GCC compressed package file name]
with the file name of the GCC compressed package you downloaded.
Create a directory for building GCC and enter that directory. Execute the following command:
mkdir build-gcc cd build-gcc
Configure GCC build options. Execute the following command:
../[GCC源代码目录]/configure --prefix=/usr/local/gcc7 --enable-languages=c,c++
Replace [GCC source code directory]
with the full path to the decompressed GCC source code directory.
Start compiling GCC. Execute the following command:
make
This will start compiling GCC, which may take some time to complete.
Install the compiled GCC. Execute the following command:
sudo make install
This will install the compiled GCC to the /usr/local/gcc7
directory.
Configure the system to use the newly installed GCC. Execute the following command:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc7/bin/gcc 100 sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc7/bin/g++ 100
Verify whether the GCC installation is successful. Execute the following command:
gcc --version
If the installation is successful, the GCC version information will be displayed.
Now, you have successfully compiled and installed the GCC 7.3.0 compiler from source code on your Ubuntu system. You can use a newly installed GCC to compile and build C and C++ programs.
The above is the detailed content of Baidu search: Lan Yiyun [Tutorial on compiling and installing gcc7.3.0 compiler from source code for ubuntu system]. For more information, please follow other related articles on the PHP Chinese website!