Get the App
SLTechnology News&Howtos  ›  Servers  › 

Makefile(07)_ path search

Shulou Source: shulou.com Published: 2022-06-03 09:27:29 12月06日 Update

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 $

Tags: Files folders search compilation paths experiments source files targets results projects variables problems different projects source code directories facets keys multiple types Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information vpn Huawei OPPO Reno