The Linux operating system is directly built on the kernel.

Source: Internet
Author: User
Tags automake

The Linux operating system is a commonly used software for computer gamers. Then I will study and study the Linux operating system in depth. Here I will discuss with you how to use the Linux operating system, I hope it will be useful to you. First of all, you should be engaged in application development in the GNU/Linux system. There should be an appropriate operating platform and development environment, therefore, selecting and installing the Linux operating system becomes the first lesson for Linux developers. Currently, many Linux operating systems are available.

For example, Red Hat's latest version is Fedora), SuSE, Mandrake, and zhongke's Red Flag), as well as the famous Debian In the open-source organization. Although there are many versions, their differences in the composition of underlying systems are minimal. We use Red Hat 9.0 As the development platform, and subsequent operations and development will be carried out on this system platform.

Figure 1 briefly describes the composition of a Linux system development tool. The underlying development tools and auxiliary tools of the Linux operating system kernel, some of which are directly built on the basis of the kernel, such as Shell, GCC, and Make; some are built on the basis of the script language, such as Automake, Autoconf, and Libtool.

They are the basis and transition of the graphic interface development tools GTK +, QT, etc.) and network application development tools Perl, PHP, and Python on the Linux operating system. Having mastered the underlying development tools, it is advantageous for external application development. This can accelerate and optimize the development of outer applications, so as to achieve a harmonious unity of development speed and development quality.

Exercise caution when selecting IDE the program editing work described in this article is mostly done using Emacs and vi commonly used in Linux systems, and compile and debug commands in the terminal window. Those who are familiar with programming in Windows will question why they don't need IDE integrated development environment). Is it a Linux OS? Of course, the answer is no.

In Linux, there are many ides. In fact, Emacs is a very good IDE. Others include CodeForge, ANJUTA, and Kdeveloper. For programmers, IDE hides many things at the underlying layer of compilation control. If software developers really understand and master these things, it is helpful to develop better applications.

IDE can be like an automatic driver on an airplane. With it, pilots will be much easier, but if the pilot doesn't really master the airplane's driving technology, if the autopilot fails during a flight, the crash is inevitable. Such a pilot cannot let him drive the plane.

This is also true for programmers. Developing software with only IDE is not enough. It is better to start with the discussion. The following describes how to compile a simple C source file. First, arrange the directory. In your own user directory, create a general directory learn-gnu, and then create the first learning directory learn-1 under this directory.

Use Emacs to edit hello in this directory. in file c, enter the following content: // hello. c # include int main (int argc, char * argv []) {int I; if (argc <= 1) {printf ("The program name is: % s \ n ", argv [0]);} else {printf (" The program name is: % s \ n ", argv [0]); for (I = 1; I printf ("The argument % d is: % s \ n", I, argv [I]) ;}}

This code tests the command line parameters and their simple usage. Normally, you can compile the code by entering the following command in the terminal: # gcc hello. after c-o hello is compiled, the executable file hello is output and executed. /hello, The following statement is output: The program name is :. /hello, this is the simplest, most primitive, most direct, and most effective compilation method learned by C language beginners. The testing method is also the simplest.

Because the code for the given use case is relatively simple, it does not need to be too complicated. The classic "Hello world" program is not used here, because I found that some students are not familiar with this program when learning C language courses. Is there a better way to compile this source program? You can compile a simple Makefile file to automatically compile the source program and generate an executable file. Table 1 contains the Makefile file.

CC = gcc. Execute make or make all to execute all: hello. the command after c, that is, compile; $ (CC) hello. c-o hello make clean: run the command "clean" to clear the compilation result. Rm hello-f use Emacs to edit it and save it to the same directory as hello. c above. Note that the file name is Makefile.

Then, enter the make command in the terminal. the following situation occurs: # make # gcc hello. c-o hello, run the column directory command again, and the generated Executable File hello: # ls hello. below is the output result of multiple parameters in c Makefile. I believe I will have a preliminary understanding of the command line parameters.

#. /Hello abc def 123 The program name is :. /hello The argument 1 is: abc The argument 2 is: def The argument 3 is: 123 Makefile is The default configuration file of The Make tool. When you execute The make command, Make will automatically find The Makefile file.

When the Linux operating system uses multiple C language source files for compilation, using Make makes the compilation process faster and more effective. Make determines whether to compile the source file based on the Update Time of the source file, that is, if the file is changed, the file will be compiled and not processed if the file is not modified. Here is a slightly complex example.

A project consists of three C language source files. c. B. c and hello. h, where. c and B. c contains hello. h. The final output executable file is hello. Table 2 contains the content of this Makefile. To learn more about the use of Make and the compilation of Makefile, you can refer to its reference document at http://www.gnu.org/manual/make-3.79.1/html_chapter/make_toc.html.

If the source program is more complex, such as adding more source files and attaching a certain amount of resources such as images and documents), or if other system support is involved, the system must install a document processing tool, syntax detection tools, development libraries of some development tools, etc.), then writing Makefile files will become very troublesome and error-prone.

In this case, you can use tools such as Autoconf, Automake, and Libtool to complete this task. This gives Makefile more functions. The Linux operating system has more complete compilation and comprehensive detection, in addition, more new features such as installation, packaging, and release are provided.

  1. Introduction to Linux operating system experimental scenarios
  2. Basic concepts of Hard Disk Partitioning in Linux
  3. Create, compile, and execute a Linux operating system
  4. The development status and trend of Linux operating system in various fields
  5. CentOS VM supports RedHat AS3/AS4/AS5Linux Operating System

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.