Lan Yiyun: Linux centos7 compilation and upgrade gcc cmake openssl tutorial

Compiling and upgrading GCC, CMake and OpenSSL on CentOS 7 systems can help you get the latest versions of these tools and libraries to meet specific needs. The following is a tutorial on compiling and upgrading GCC, CMake and OpenSSL on CentOS 7:

Compile and upgrade GCC:

  1. Install the necessary dependencies:
    First, install the dependency packages required to compile GCC:
sudo yum install -y gcc gcc-c++ make
  1. Download and compile GCC:
    Download the latest version of GCC source code from the GCC official website, then unzip it and enter the source code directory:
tar xzf gcc-x.x.x.tar.gz
cd gcc-x.x.x

Create a directory for compilation and execute the configure command to configure GCC compilation options:

mkdir build
cd build
../configure --enable-languages=c,c++ --disable-multilib

Execute the make command to start compiling GCC:

make -j$(nproc)
  1. Install GCC:
    After compilation is complete, use the following command to install the new version of GCC:
sudo make install

Compile and upgrade CMake:

  1. Download and compile CMake:
    Download the latest version of CMake source code from the CMake official website, then unzip it and enter the source code directory:
tar xzf cmake-x.x.x.tar.gz
cd cmake-x.x.x

Execute the following commands to compile and install CMake:

./bootstrap
make -j$(nproc)
sudo make install

Compile and upgrade OpenSSL:

  1. Download and compile OpenSSL:
    Download the latest version of OpenSSL source code from the OpenSSL official website, then unzip it and enter the source code directory:
tar xzf openssl-x.x.x.tar.gz
cd openssl-x.x.x

Execute the following commands to configure, compile and install OpenSSL:

./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make -j$(nproc)
sudo make install
  1. Configure environment variables: Add the following environment variables
    to  /etc/profilethe file to ensure that the system can find the newly compiled GCC, CMake, and OpenSSL:
export PATH="/usr/local/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"

After saving the file, run the following command to make the environment variables take effect:

source /etc/profile

After completing the above steps, you have successfully compiled and upgraded GCC, CMake and OpenSSL on CentOS 7 system. Please note that compiling and upgrading these tools and libraries may take a long time and may be complex for users unfamiliar with the compilation process. Therefore, before upgrading, be sure to back up important data and make sure you understand the use and configuration of these tools and libraries.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/133323968