Home  >  Article  >  Computer Tutorials  >  Baidu search: Lan Yiyun [Tutorial on compiling and installing gcc7.3.0 compiler from source code for ubuntu system]

Baidu search: Lan Yiyun [Tutorial on compiling and installing gcc7.3.0 compiler from source code for ubuntu system]

WBOY
WBOYforward
2024-03-27 20:30:28605browse

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:

  1. Log in to your Ubuntu system.
  2. 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.

  3. 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.

  4. 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.

  5. Create a directory for building GCC and enter that directory. Execute the following command:

    mkdir build-gcc
    cd build-gcc
  6. 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.

  7. Start compiling GCC. Execute the following command:

    make

    This will start compiling GCC, which may take some time to complete.

  8. Install the compiled GCC. Execute the following command:

    sudo make install

    This will install the compiled GCC to the
    /usr/local/gcc7 directory.

  9. 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
  10. 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!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete