程序代写代做代考 CSci 4061 – cscodehelp代写
CSci 4061
Discussion week 3
Overview
¡ñ Makefile ¡ñ gdb
¡ñ man pages
¡ñ Exercise / Quiz
Makefile
Makefile
¡ñ Organize code compilation process
¡ð Describes relationship between source code, intermediate files and executables
¡ñ Example : Building an application
¡ð Build libraries first and then combine to form the application executable
¡ñ In short, set of rules to build an application (mostly)
Rules
¡ñ Target : Executable to be made
target: prereq1 prereq2
recipes
¡ñ Prereq : Files that must exist before target is created
¡ñ Recipes : Create target from prereqs
Example
Target : foo.o
Prereq : foo.c foo,h Recipe : gcc foo.c -o foo.o
foo.o : foo.c foo.h
gcc foo.c -o foo.o
Phony
¡ñ Target¡¯s recipes executed only if there were changes to prereqs
¡ñ If there are no prereqs and a file named ¡®target¡¯ exists, then ¡®make¡¯ will not run
the recipe as it believes ¡®target¡¯ file is unchanged.
¡ñ Solution : Declare target as .PHONY .PHONY: clean
clean:
rm *.o temp
gdb
gdb
¡ñ GNU Debugger tool
¡ñ gdb prog – Start gdb session on pgm
¡ñ break
¡ñ run [
args
¡ñ print – Print the value of variable var
¡ñ watch – gdb will pause and display information when the value of
the variable var is updated
man pages
¡ñ Documentation on the Linux kernel and C library interfaces ¡ñ Example:
$man printf
Displays the manual page for printf function
Exercise / Quiz
Today¡¯s Task
¡ñ Quiz on Canvas, due 11:59 pm Tuesday (tomorrow)
¡ñ Lab Exercise:
¡ð Given 5 source files and corresponding headers
¡ð Complete the given Makefile and generate the ¡°main¡± output file