Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get started with makefile

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to get started with makefile. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.

The makefile file is used to help compile and manage the C++ project code and needs to be used with the make command. Other shell operations can also be performed in makefile, with some of the functions of .sh scripts.

Makefile content is written according to the following rules

Goal 1: rely on 1 command 1

Goal 2: rely on 2 command 2

Goal 3: rely on 3 commands 3. Target N: rely on N command N

The command can be any shell statement. In most cases, commands perform the function of generating targets from dependencies. For example, if you generate a .o file from a .cpp file, the command must include the complete compilation command for gathers + and some compilation parameters.

Goal 1-2-3 can be a nested dependency, and if dependency 1 contains goal 2, goal 3, it is a nested dependency. Can also be independent, for example, goal 123 is three independent executable files, or three dynamic libraries, then there can be no dependency between them, written in a makefile file just for unified management.

Start with a tab before the command. If you use spaces instead of tab, you will report when you execute the make command

[root@localhost makefiletest] # makemakefile:5: * missing separator (did you mean TAB instead of 8 spaces?) Stop.

Take the following simple C++ code as an example to illustrate the specific use of makefile.

Source code file test.cpp

# include # include # include

Int main (int argc, char** argv) {using namespace std;int I = 1; int j = 2; j + = 3 position cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report