Linux basic configuration and management 7 ---- software installation: Source code and Tarball

Source: Internet
Author: User
1. Introduction to installation and upgrade of open-source software 1. software on Linux is almost licensed by GPL, so almost every software provides the source code, in addition, you can modify the program code 2 on the Linux system. Can a file be executed?

1. Introduction to open source software installation and upgrade

1 The software on Linux is almost always authorized by GPL, so almost every software provides the source code, and you can modify the program code on your own.

2 In Linux, whether a file can be executed depends on whether there is the executable permission (with the x permission). However, the executable file actually identified on Linux is a binary file, for example,/usr/bin/passwd

3. the program code file is actually a general plain text file. after writing the source code file, the next step is to "compile" the file into a binary file that the operating system can understand. to compile the file, you must write a "compile program" to operate it, after compilation and linking, a executable binary program is generated.

4. In short, we can say so.

Open source code: it is the program code that is written to humans. but the machine does not know it, so it cannot be executed.

Compile a program: translate the program code into a language that the machine can understand, just like the role of the editor.

Executable files: The files that can be executed by the machine after the compiled program is converted into a binary program

5. the Function Library is similar to a subprogram role and can be called to execute a function. Static function library and dynamic function library

6 sometimes there are a bunch of program code files that we need to manually compile, but many compilation commands make us write crazy, at this time, we can use the relevant functions of the make command to simplify the compilation process.

7. when you execute make, make searches for the Makefile text file in the current directory, while Makefile records the details of how to compile the source code, make will automatically identify whether the source code is changed and automatically update the execution file

8. how is makefile generated? In general, we have a configure currently. this configure detection program can find the required function library, compiler, and other information.

9 The so-called Tarball file is actually to pack all the source code files of the software with tar and then compress them with compression technology. Generally, the most common one is gzip compression, because the tar and gzip functions are used, the extension of the tarball file is * .tar.gz or *. tgz

10. how is the tarball of a software installed? the basic process is as follows:

1. download the tarball from the vendor's webpage.

2. decompress the tarball to generate many source code files.

3. start to compile the source code with gcc (the target file will be generated)

4. Then, use gcc as the function library, main program, and subprogram link to form the main binary file.

5. install the preceding binary file and related file configurations on your host.

Second, a simple example of compiling using traditional programming languages

1 by default, if we directly compile the source code with gcc without adding any parameters, the file name of the execution file will be automatically set to a. out.

2. simple gcc usage

1 gcc-c tmp. c

-The c parameter only compiles the source code into the target file and does not create links.

The tmp. o file is generated, but the executable file is not generated.

2 gcc-o tmp. c-c

-O parameter optimization speed based on the operating environment during compilation

The tmp. o file is automatically generated and optimized.

3 gcc tmp. c-lm

-Lm indicates the library file libm. so or libm..

4 gcc-o main tmp. c-wall

-O tmp specifies that the generated executable file is main

-Wall lists detailed information.

Management and suggestions of three tarballs

1. most of the basic operations for installing Tarball are as follows:

1. obtain the source file: decompress the tarball file in the/usr/local/src directory.

2. Procedure: under the newly created directory, check the INSTALL, README, and other related files.

3. INSTALL related software: check and INSTALL the software according to INSTALL/README.

4. create makefile: to automatically detect the configure detection operating environment of the program, and create the Makefile file.

5. Compile the program: Use the Makefile in the directory as its parameter configuration file to compile the program.

6. install the program by using make and the Makefile parameter configuration file, and install the target to the correct path.

2 The so-called update source code is only a small part. many software developers release the so-called patch file after updating the source code.

3. after downloading the patch file, we can update the source code of your software. However, if we update the source code, we will not update the software, we also need to compile the software to make it the final correct software, because the patch function mainly updates the source code.

4. we can use the MD5 fingerprint verification mechanism to determine whether the file has been changed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.