ابزار کاربر

ابزار سایت


c-programming:makefile:example

این یک نگارش قدیمی از این مطلب است!


Example

# define the C compiler to use
CC       = gcc
# define comipler flags
CFLAGS   = -std=c11 -Wall -fmax-errors=10 -Wextra
# define library paths in addition to /usr/lib
LFLAGS   = -L. 
# define libraries to use
LIBS     = -lweather
# define the object files that this project needs
OBJFILES = program.o
# define the name of the executable file
MAIN     = program
 
# all of the below is generic - one typically only adjusts the above
 
all: $(MAIN)
 
$(MAIN): $(OBJFILES)
    $(CC) $(CFLAGS) -o $(MAIN) $(OBJFILES) $(LFLAGS) $(LIBS) 
 
%.o: %.c
    $(CC) $(CFLAGS) -c -o $@ $<
 
launch: program
	./program
 
clean:
    rm -f $(OBJFILES) $(MAIN)
Intermediate step:
 
program: program.o
	gcc -std=c11 -Wall -fmax-errors=10 -Wextra program.o -L. -lweather -o program
 
program.o: program.c
	gcc -std=c11 -Wall -fmax-errors=10 -Wextra -c program.c -o program.o
 
launch: program
	./program
c-programming/makefile/example.1713564018.txt.gz · آخرین ویرایش: 2024/04/20 01:30 توسط nasser

به جز مواردی که ذکر می‌شود، مابقی محتویات ویکی تحت مجوز زیر می‌باشند: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki