Composition and installation of C development environment under Linux operating system

  
                  

This article introduces the composition and installation of the Linux C development environment, so that readers can have a preliminary understanding of the Linux C development environment. Do you know Linux? I believe that more and more people will say "yes" now. So how much do you know? It is undeniable that most Linux users are still at a relatively low level in understanding Linux. They may have several commands, several services, rpm to install software, KDE/Gnome, etc. But when they encounter software that needs to be compiled and installed, they are at a loss when faced with some simple error messages. In order to truly leapfrog these primary levels, you can't understand some of the underlying things, such as the C development environment under Linux and other operating system knowledge outside of this article. Linux and C are born with a mystery. You may know that Linux's operating system kernel is mainly written in C. In addition, many software under Linux is written in C, especially some well-known service software, such as MySQL and Apache. Wait. Beginners may have encountered a variety of errors when compiling software such as MySQL. In fact, as long as you have a basic understanding of the Linux C development environment, you can choose to solve some errors in the installation process. The Linux C development environment is different from Windows. Under Linux, a complete C development environment consists of the following three components: 1, function library: glibc
To build a complete C development environment, Glibc It is essential, it is the main function library of C under Linux. There are two ways to install Glibc: A. Install the function library for testing, and try out the new library with different options when compiling the program. B. Installed as the main C function library, the function library used by all new compilers. Glibc2 contains several additional packages: LinuxThreads, locale, and crypt. Usually their file names vary from version to version 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 GNU's powerful and superior performance Multi-platform compiler, gcc compiler can compile and link C, C++ language source program, assembly program and target program into executable file. The following are the suffixes of some source files supported by gcc and their explanations: .c The suffix file, the C language source code file; the .a suffix file is the archive file composed of the target file; the .C, .cc or .cxx suffix file is the C++ source code file; .h is The suffix file is the header file included in the program; the .i suffix file is the pre-processed C source code file; the .ii suffix file is the pre-processed C++ source code file; .m The file with the suffix is ​​the Objective-C source code file; the text with the .o is the suffix Is the object files compiled; .s suffix files, assembly language source code files; .S suffix file is pre-compiled assembly language source code files.
3, system header file: glibc_header
If the system header file is missing, many C programs that use system functions will not compile. If the user installs less of these packages during the installation process, the C source will not compile. Beginners sometimes choose their own custom packages to install, and the results are missing these packages, resulting in the inability to compile the source program, many people have to re-install Linux. In fact, you don't need to do this. Although it is difficult for beginners to install Linux C from the tarball, we can quickly install the Linux C development environment through the rpm package. Let's take Red Hat 7.3 as an example to introduce how to install the Linux C development environment. If it is a later version of Red Hat, you can also refer to it, just pay attention to the difference in software version. Since the gcc package needs to rely on binutils and cpp packages, the make package is also commonly used in compilation, so a total of 8 packages are required to complete the 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 connected to the internet, you can install it directly from the internet. The commands are as follows:
rpm -ivhftp: //216.254.0.38/linux/redhat/7.3/en/os/i386/RedHat/RPMS/cpp-2.96-110.i386.rpmrpm -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, download it and install it. After the installation, it constitutes the most basic C development environment, in this C development environment, you can compile most C-written applications. For a C program, the installation can usually be divided into three components: 1. Executable file 2. Include file 3. Library file executable file is the final run command, the include file is some definition of the C program include The file, the library file is a custom library of the C program. For example, for MySQL installed with RPM: the executable file is placed under /usr/bin, the include file is placed under /usr/include/mysql, and the library file is under /usr/lib/mysql. Only the system can find the corresponding file and library files corresponding to the program, and the program executable file can run normally. Understand the composition and installation of the Linux C development environment, it is still not enough, but also need to study and learn in depth, in order to be able to "know it, know why."


Copyright © Windows knowledge All Rights Reserved