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

Makefile(07)_ path search

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Path search in 17.Make _ on 17.0. Experimental material

The source file is located in: src directory

Source file: main.c

# include # include "func.h" int main () {foo (); return 0;}

Source file: func.c

# include # include "func.h" void foo () {printf ("void foo ():% s\ n", "Hello, D.T.Software...");}

The header file is located in: inc directory

Header file func.c

# ifndef FUNC_H#define FUNC_Hvoid foo (); # endif17.1. Project source code organization mode

Question: in an actual project, are all the source files and header files in one folder?

In an actual project, the source code and header files are divided according to modules, as shown below:

The makefile in the project must be able to correctly locate the source and dependency files, and eventually compile to produce an executable program.

Lab 1:

Can the following makefile be compiled successfully when the source code organization directory is as follows?

OBJS: = func.o main.ohello.out: $(OBJS) @ gcc-o $@ $^ @ echo "Target File = > $@" $(OBJS):% .o:% .c func.h @ gcc-o $@-c $

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

Servers

Wechat

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

12
Report