Makefiles & Project 1 Q&A 15-441 Recitation 2 441 Staff.

Slides:



Advertisements
Similar presentations
Makefile Ansuman Banerjee Arijit Bishnu Debapriyo Majumdar Data and File Structures Lab M.Tech. Computer Science 1 st Year, Semester I Indian Statistical.
Advertisements

Compiling. Your C, C++ or Fortran program won’t work unless you compile it The compiler will build your program as an executable file (typically in the.
Separate compilation Large programs are generally separated into multiple files, e.g. tuples.h, ray.h, ray.c, tuples.c main.c With several files, we can.
Practical software engineering: Revision control & make Spring 2010, Recitation #2.
The Makefile utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
Makefiles Tutorial adapted from and myMakeTutorial.txt.
1 The Makefile Utility ABC – Chapter 11,
Systems Dev. Tutorial II: Make, utilities, & scripting Recitation Wednesday, Sept 13 th, 2006.
The Makefile Utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
ECE 353 WinAVR and C Debugging Tutorial By Adam Bailin ECE 353 Fall ‘06.
Makefiles, Unix, and Project 1 Q&A : Recitation 2 September 12, 2007.
Tutorial 0 SimpleScalar Installation CPEG-323 Intro. To Computer Engineering Tom St. John September 19, 2008.
The Makefile Utility ABC – Chapter 11, Motivation Small programs single file “Not so small” programs : –Many lines of code –Multiple components.
How to Write a.c File : Introduction to Computer Systems Recitation 6, Oct 1, 2012 Alexander Malyshev (amalyshe) Section A, 10:30a – 11:20p, WeH.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Makefiles, and.h files, and.c files, and.o files, OH MY! For projects with more complexity. (Great.. Just what we needed)
Make: the good, the bad, and the ugly Dan Berger Titus Winters
CIS*2450 Seminar I Makefiles Debugging/Design Approaches Exception Handling Library Revision Control Designed by: Terry Moreland Updated by: Tom Crabtree.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
Makefiles CISC/QCSE 810. BeamApp and Tests in C++ 5 source code files After any modification, changed source needs to be recompiled all object files need.
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
Old Chapter 10: Programming Tools A Developer’s Candy Store.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
System Programming - LAB 1 Programming Environments.
Makefile M.A Doman. Compiling multiple objects Card.cpp -> Card.o Deck.cpp -> Deck.o main.cpp -> main.o main.o Deck.o Card.o -> Dealer.exe.
CCA Common Component Architecture Ccaffeine Convenience Scripts 1 setup_path script export SIDL_DLL_PATH=“” DL_PATH=$BABEL_ROOT/lib for i in `ls $TUT_COMP_ROOT.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
1 Topics for this Lecture Build systems Static analysis.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
15213 Recitation Section C Introduction Unix and C Playing with Bits Practice Problems Shimin Chen Sept. 9, 2002 Outline.
Basic of UNIX For fresh members of SPARCS
NETWORK PROGRAMMING INTRO TO DISTRIBUTED SYSTEMS FALL 2015 L3-socket Dongsu Han Some material taken from publicly available lecture slides including Srini.
Makefiles CARYL RAHN. Separate compilation Large programs are generally separated into multiple files, e.g. main.c addmoney.c removemoney.c money.h With.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015 Makefile Tutorial CIS5027.
Lecture 8  make. Using make for compilation  With medium to large software projects containing many files, it’s difficult to: Type commands to compile.
Make Make is a system utility that automatically compiles your programs for you Make looks for a file named Makefile (or makefile) in the current directory.
C code organization CSE 2451 Rong Shi. Topics C code organization Linking Header files Makefiles.
Advanced UNIX progamming Fall 2002 Instructor: Ashok Srinivasan Lecture 2 Class web site:
CSc 352 An Introduction to make Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Makefile Script file to automate program compilation and linking (making) 1. Write the "makefile" 2. Write your programs 3. Run "make" or "make -f makefile"
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
UNIX Development: g++ and make CS 2204 Class meeting 8 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
ScienceTools Linux Instructions Windows Instructions.
CSCI 4061 Recitation 2 1.
Makefiles CSSE 332 Operating Systems
The make utility (original presentation courtesy of Alark Joshi)
CSE 303 Lecture 17 Makefiles reading: Programming in C Ch. 15
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Brief Intro to Make CST494/ Gannod.
Makefiles Caryl Rahn.
Editor, Compiler, Linker, Debugger, Makefiles
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
CS 60 Discussion Review.
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Makefiles and the make utility
עבודה עם Eclipse מבוא לתכנות מערכות מבוא לתכנות מערכות.
Makefiles and Notes on Programming Assignment PA2
CMPSC 60: Week 4 Discussion
Build Tools (make) CSE 333 Autumn 2018
Preparation for Assignment 2
CSc 352 An Introduction to make
Makefiles and the make utility
Makefiles, GDB, Valgrind
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
g++ features, better makefiles
The make utility (original presentation courtesy of Alark Joshi)
Presentation transcript:

Makefiles & Project 1 Q&A Recitation Staff

Outline gcc make and Makefile Useful commands Project 1 Q&A

Simple gcc If we have files: prog.c: The main program file lib.c: Library.c file lib.h: Library header file % gcc -c prog.c -o prog.o % gcc -c lib.c -o lib.o % gcc lib.o prog.o -o binary

gcc flags Useful flags 1.-g: debugging hook 2.-Wall: all warning 3.-Werror: treat warning as errors 4.-O2, -O3: optimization 5.-DDEBUG: macro for DEBUG (#define DEBUG)

Examples %gcc -g -Wall -Werror -c prog.c -o prog.o %gcc -g -Wall -Werror -c lib.c -o lib.o %gcc -g -Wall -Werror lib.o prog.o -o binary But Don’t Repeat Yourself!

Makefile %gcc -g -Wall -Werror -c prog.c -o prog.o %gcc -g -Wall -Werror -c lib.c -o lib.o %gcc -g -Wall -Werror lib.o prog.o -o binary CC = gcc CFLAGS = -g -Wall -Werror OUTPUT = binary

Makefile target: dependency1 dependency2... unix command (start line with TAB) unix command... % gcc lib.o prog.o -o binary binary: lib.o prog.o gcc lib.o prog.o -o binary

binary: lib.o prog.o gcc -g -Wall lib.o prog.o -o binary lib.o: lib.c gcc -g -Wall -c lib.c -o lib.o prog.o: prog.c gcc -g -Wall -c prog.c -o prog.o clean: rm *.o binary

binary: lib.o prog.o gcc -g -Wall lib.o prog.o -o binary lib.o: lib.c gcc -g -Wall -c lib.c -o lib.o prog.o: prog.c gcc -g -Wall -c prog.c -o prog.o clean: rm *.o binary

CC = gcc CFLAGS = -g -Wall OUTPUT = binary $(OUTPUT): lib.o prog.o $(CC) $(CFLAGS) lib.o prog.o -o binary lib.o: lib.c $(CC) $(CFLAGS) -c lib.c -o lib.o prog.o: prog.c $(CC) $(CFLAGS) -c prog.c -o prog.o clean: rm *.o $(OUTPUT)

CC = gcc CFLAGS = -g -Wall OUTPUT = binary $(OUTPUT): lib.o prog.o $(CC) $(CFLAGS) lib.o prog.o -o binary lib.o: lib.c $(CC) $(CFLAGS) -c lib.c -o lib.o prog.o: prog.c $(CC) $(CFLAGS) -c prog.c -o prog.o clean: rm *.o $(OUTPUT)

CC = gcc CFLAGS = -g -Wall OUTPUT = binary OBJFILES = lib.o prog.o $(OUTPUT): $(OBJFILES) $(CC) $(CFLAGS) $(OBJFILES) -o binary lib.o: lib.c $(CC) $(CFLAGS) -c lib.c -o lib.o prog.o: prog.c $(CC) $(CFLAGS) -c prog.c -o prog.o clean: rm *.o $(OUTPUT)

CC = gcc CFLAGS = -g -Wall OUTPUT = binary OBJFILES = lib.o prog.o $(OUTPUT): $(OBJFILES) $(CC) $(CFLAGS) $(OBJFILES) -o binary lib.o: lib.c $(CC) $(CFLAGS) -c lib.c -o lib.o prog.o: prog.c $(CC) $(CFLAGS) -c prog.c -o prog.o clean: rm *.o $(OUTPUT)

CC = gcc CFLAGS = -g -Wall OUTPUT = binary OBJFILES = lib.o prog.o $(OUTPUT): $(OBJFILES) $(CC) $(CFLAGS) $(OBJFILES) -o binary %.o: %.c # $<: dependency (%.c) # target (%.o) $(CC) $(CFLAGS) -c $< -o clean: rm *.o $(OUTPUT)

Simple Test Script %./server 6667 & % cat testfile.01 |./testscript.py % cat testfile.02 |./testscript.py % killall -9 server

Simple Test Script #/bin/sh echo “Starting server on port 6667.”./server 6667 & SERVERPID = $! echo “Running test files.” cat testfile.01 |./testscript.py cat testfile.02 |./testscript.py echo “Killing server process.” kill $(SERVERPID)

CC = gcc CFLAGS = -g -Wall OUTPUT = binary OBJFILES = lib.o prog.o all: $(OUTPUT) $(OUTPUT): $(OBJFILES) $(CC) $(CFLAGS) $(OBJFILES) -o binary %.o: %.c # $<: dependencies (%.c) # target (%.o) $(CC) $(CFLAGS) -c $< -o clean: rm *.o $(OUTPUT)

CC = gcc CFLAGS = -g -Wall OUTPUT = binary OBJFILES = lib.o prog.o all: $(OUTPUT) test $(OUTPUT): $(OBJFILES) $(CC) $(CFLAGS) $(OBJFILES) -o binary %.o: %.c # $<: dependencies (%.c) # target (%.o) $(CC) $(CFLAGS) -c $< -o test: $(OUTPUT) sh./testscript.sh clean: rm *.o $(OUTPUT)

Use Makefile % make % make test % make clean Google – “makefile example” – “makefile template” – “make tutorial”

Useful Unix Commands find “func_name” in files % grep -r func_name. replace “bad_func_name” to “good_func_name” % sed -e “s/bad_func_name/good_func_name/g”\ prog.c > prog.c.new

Useful Unix Commands find a file named “prog.c” % find -name prog.c download files from Internet % wget untar and unzip the file % tar xzvf file.tar.gz

Project 1 Checkpoint 2 – Echo server – Handle multiple clients – Handle TCP framing Q & A