Almost all software on Linux is GPL licensed, so almost all software will provide source code.
To be executed on Linux, a software must be a binary file. Therefore, when we get the software source code, we need to compile it into a binary file before it can be run on Linux.
Software compilation process
It takes two steps to compile the source code into a binary file that can be run on Linux: linux operation and maintenance)
1. Use the gcc compiler to compile the source code into a target file
2. Use the gcc compiler again to link the target file into a binary file
This process seems simple, but in fact it is not. The source code of a software is often encapsulated in multiple source files. In addition, these files have intricate dependencies, and compilation needs to be carried out in strict accordance with the specified order, which undoubtedly increases the difficulty of compilation. Fortunately, the make command can help us simplify the compilation process.
The entire compilation process is condensed in the Makefile file (telling the make command how to compile and link the program). When the make command is executed, make will go to the current directory to find the Makefile file, and based on the file It is required to complete the entire compilation process.
The Makefile file is generated by the configure command. When executing the configure command, configure will dynamically generate a Makefile suitable for this system based on the current system environment for use by the make command.
Linux source code installation steps
Get the source code
Download the source code of the software to /usr/local/ and unzip it .
View the INSTALL and README files
After decompression, view the INSTALL and README files. These two files introduce in detail the installation method and precautions of this software.
Create a Makefile
Execute the configure command to generate a Makefile.
Compile
Execute the make clean;make command to compile the source code into a binary file.
PS: The make clean command is used to clear the target files generated by the last compilation. This step is optional, but in order to ensure the success of compilation, it is better to add it. Prevent compilation failure due to residual object files in the software.
Installation
Execute the make install command to install the binary file compiled in the previous step into the specified directory.
The above is the detailed content of Installation steps of linux source code. For more information, please follow other related articles on the PHP Chinese website!