Do you know about Linux? I believe that more and more people will say "yes. To what extent do you know? It is undeniable that most Linux users are still at a relatively low level of understanding about Linux, they may execute several commands, configure several services, use RPM to install software, operate the KDE/gnome interface, and so on. But when they encounter software that needs to be compiled and installed, in the face of some simple error information, they are helpless. If you really want to jump to these basic levels, you will not be able to understand some underlying things, such as the C development environment in Linux and other operating system knowledge in this article.
Linux and C are born with an unknown source. You may know that the Linux operating system kernel is mainly written in C, and many software in Linux is written in C, especially some well-known service software, such as MySQL and Apache. Beginners may encounter various errors when compiling software such as MySQL. In fact, as long as you have a preliminary understanding of the Linux C development environment, you can choose to solve some errors during the installation process.
The C development environment in Linux is different from that in windows. In Linux, a complete C development environment consists of the following three components:
1. function library: glibc
To build a complete C development environment, glibc is essential. It is the main function library of C in Linux. Glibc has two installation methods:
A. Install the function library for testing and use different options to try the new function library during program compilation.
B. Install it as the main c function library, which is used by all newly compiled programs.
Glibc2 contains several additional packages: linuxthreads, locale, and crypt. Generally, their file names vary with versions and are similar to the following file names:
Glibc-2.06.tar.gz
Glibc-linuxthreads-2.0.6.tar.gz
Glibc-localedate-2.0.6.tar.gz
Glibc-crypt-2.0.6.tar.gz
2. Compiler: gcc
GCC (GNU ccompiler) is a GNU multi-platform compiler with powerful functions and superior performance, the GCC compiler can compile and connect the C and C ++ language source programs, programming sequences, and target programs into executable files. The suffixes and explanations of some source files supported by GCC are as follows:
. C is a suffix file, C language source code file;
. A is a file with a suffix. It is a file library consisting of the target file;
. C,. cc or. cxx is a C ++ source code file;
. H is a suffix file, which is the header file included by the program;
. I is a file with a suffix. It is a pre-processed C source code file;
. II is a file with a suffix. It is a pre-processed C ++ source code file;
. M is a suffix file, which is an objective-C source code file;
The. o file is the compiled target file;
. S is a suffix file, which is an assembly language source code file;
. S is a precompiled assembly language source code file.
3. System header file: glibc_header
If the system header file is missing, many C Programs that use system functions cannot be compiled.
If the user installs less packages during the installation process, the C source program cannot be compiled. Beginners sometimes choose their own customized software packages for installation. As a result, these packages are missing, and the source program cannot be compiled. Many people have to reinstall Linux. In fact, this is not necessary. Although it is difficult for beginners to install the Linux C development environment from the tar package, we can still install the Linux C development environment quickly through the RPM package. The following uses Red Hat 7.3 as an example to describe how to install the C development environment of Linux. For a later version of Red Hat, you can refer to it, but pay attention to the different software versions.
The GCC package depends on binutils and CPP packages, and make packages are also commonly used in compilation. Therefore, a total of 8 packages are required for installation. They are:
Cpp-2.96-110.i386.rpm
Binutils-2.11.93.0.2-11.i386.rpm
Glibc-2.2.5-34.i386.rpm
Glibc-kernheaders-2.4-7.14.i386.rpm
Glibc-common-2.2.5-34
Glibc-devel-2.2.5-34.i386.rpm
Gcc-2.96-110.i386.rpm
Make-3.79.1-8.i386.rpm
If it is connected to the Internet, you can install it directly from the Internet. The commands are as follows:
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/cpp-2.96-110.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/binutils-2.11.93.0.2-11.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/glibc-kernheaders-2.4-7.14.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/glibc-2.2.5-34.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/glibc-devel-2.2.5-34.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/glibc-common-2.2.5-34.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/gcc-2.96-110.i386.rpm
Rpm-IVH
FTP: // 216.254.0.38/Linux/RedHat/7.3/en/OS/i386
// RedHat/RPMS/make-3.79.1-8.i386.rpm
If it is not connected to the Internet, you need to download and install it. Generally, these packages are also available in the system's ISO. You can mount them and check it. GDB is also in it. After installation, the most basic C development environment is formed. In this c development environment, you can compile most applications written in C. For a C program, after the installation is complete, it can be divided into three components:
1. executable files
2. Include files
3. library files
The executable file is the final run command. The include file is some definition files of the C program include, and the library file is the custom library of the C program. For example, for MySQL installed with RPM: the executable files are stored in/usr/bin, including files in/usr/include/MySQL, and the library files are stored in/usr/lib/MySQL. Only the system can find the files and library files corresponding to the program, and the executable files of the program can run normally.
It is not enough to understand the composition and installation of the C development environment of Linux. You still need to study and study it in order to "know it, know it ".