Makefile, an adhesive for Linux development tools in C ++ language

Source: Internet
Author: User
Tags perl script
I want to use the word "adhesive" to express the "glue" that binds multiple tools ". For example, through shell scripts, we can concatenate OS commands, sed commands, awk commands, and other script files to bring them together. In linuxC ++ programming,

I want to use the word "adhesive" to express the "glue" that binds multiple tools ". For example, through shell scripts, we can concatenate OS commands, sed commands, awk commands, and other script files to bring them together. In linux C ++ programming, we will inevitably use C ++ as the Linux development tool adhesive makefile file. Through it, we can concatenate compilation commands, generate document operations, clear operations, and so on. In a sense, it is also equivalent to a binder.

The starting point of making the Linux development tool adhesive Makefile in C ++ is to maintain the dependency between many files in a project and obtain the topology of a source program. When we only modify a node in the graph, we only need to compile the link associated with the topology graph during re-compilation. This greatly shortens the compilation time. Make has two concepts: dependencies and rules. Rule defines an operation rule for each dependency. This fine-grained separation allows us to customize the behavior of software building. For example, modify the compiler used, modify includepath, modify libpath, and modify compilation options. The nmake function in our common VC is similar to make.

The key and difficulty of using make is to compile the Makefile file, which is used as the adhesive for Linux development tools in C ++ language. Makefile syntax is quite different from other languages. we should pay special attention to the differences between the TAB key and the space key. There are many tools to help us generate Makefile. The most famous is GNU autoconf. For compiling a GNU program, four tools are required: autoscan, aclocal, autoconf, and automake.

We know that the three steps for installing the GNU software are:./configure, make, make install. ./Configure generates a makefile based on tools such as autoconf and alocal. The make command is to call the make command to compile the source program according to the rules of the makefile file. Make install is the operation (usually the copy operation) specified by the install rule in makefile ). Make clean is the operation specified by the clean rule in makefile (usually the rm operation ). When we use Eclispe + CDT to develop a Managed C ++ Project, it generates Makefile through the objects. mk, subdir. mk, and sources. mk files. Observe the output information during compilation to see the contents of the Makefile file.

It can be said that if you want to compile a cross-platform C ++ program, using C ++ as the Linux development tool Makefile is the most convenient mechanism.

OCI is the ACE of Douglas C. Schmidt. The TAO open-source community has compiled a great perl script, called MPC. It generates project files, such as Make, Nmake, Visual C ++ 6, and Visual C ++ 7, based on the platform information, a rule file, and source code. Google Web Tookit and Celtix do similar things, but they are for JAVA, while PC is for C ++.

Related Article

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.