Configuration and installation of the C development environment under Linux
This article describes the composition and installation of Linux's C development environment, making readers to have a preliminary understanding of Linux's C development environment.
Do you know Linux? I believe that more and more people will say "yes". So what extent you know? It is undeniable that most Linux users currently have a relatively low level of Linux, and they may have several commands, they will use rpm to install software, they will operate KDE / GNOME link, etc. But when they encounter some software that needs to be compiled, they face some simple error messages, they have no hand. If you want to truly cross these primary levels, you can't understand some underlying things, such as the C development environment under Linux you want to talk about this article and other operating system knowledge other than this article.
Linux and C are born, you may know that Linux's operating system kernel is mainly written in C, and many software under Linux is written, especially some famous service software, such as MySQL, Apache Wait. Beginners may encounter a variety of errors when compiling the software like MySQL, in fact, as long as you have learned Linux's C development environment, you can choose some of the errors in the installation process.
Linux's C development environment is different from Windows. Under Linux, a complete C development environment includes the following three components:
1, Library: GLIBC
To archive a complete C development environment, Glibc is essential, it is the main function library of C under Linux. GLIBC has two installation methods:
A. Function library installed as tests Use different options in compilers to try new function libraries B. Installing the main C-Library All new compilers are used in the library GLIBC2 with several additional packages: LinuXThreads, Locale and Crypt, usually their file names 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 powerful and superior multi-platform compiler introduced by GNU. The GCC compiler can compile C, C language source programs, conventional order and target programs, connected to executables, the following is GCC Support some of the suffixes of some source files and their explanations:
.c for the suffix file, C language source code file; .a is the file file, which is the file file composed of the target file; .c, .cc, or .cxx is the suffix file, is a C source code file; H is a subscripted file, which is the header file contained in the program; the file for the suffix is a pre-processed C source code file; .ii is a composite file, is a pre-preached C source code file; .m is the composite file, is the Objective-C source code file; .o is a subscripted file, which is a compiled target file; .s is a subscripted file, is a compilation language source code file ;.s is a file of the suffix, It is a precompiled assembly language source code file.
3, system header file: glibc_header
Many C processes that use system functions will not be compiled.
If the user eliminates these packs less during the installation process, the C source program will not be compiled. Beginners sometimes choose their own custom software bags to install, and the results are missing these packages, resulting in unable to compile the source program, many people have to reinstall Linux. In fact, it doesn't matter, although the C development environment installed Linux from the Tar bag is more difficult for beginners, but we can quickly install Linux C development environment via the RPM bag. The following is taken as an example of Red Hat 7.3, describes how to install Linux's C development environment. If it is a higher version of Red Hat, you can refer to it, just pay attention to the software version. Since the GCC package needs to rely on binutils and CPP packages, the MAKE package is also commonly used in compilation, so 8 packs are required to complete the installation, they are:
CPP-2.96-110.i386.93.0.2-11.i386.0.0.2-11.i386.0.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.1-86.rpm make-3.79.1-8.i386.rpm If you connect on the Internet, you can install directly from the Internet. The command 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.0.2-11.i386.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 you are not even on the Internet, you have to download it. After installation, it constitutes the most basic C development environment. In this C development environment, most C write applications can be compiled. For a C program, it can usually be divided into three compositions after installation is:
1. Executable file 2. Contains files 3. Library files
The executable is the final command, and the included file is some definition files for the C program include, the library file is the C program custom library. For example, for the mysql installed with rpm: Under / usr / bin installed, the library file is placed under / usr / lib / mysql under / usr / include / mysql. Only the system can find the contents of the program corresponding to the program and library files, the program executable file can run normally. Understand the composition and installation of Linux's C development environment, still inadequate, you need to "know it, know if it is," you can do it.