Makefile Basics and GCC Compiler Flags

FriendlyTin avatar
FriendlyTin
·
·
Download

Start Quiz

Study Flashcards

18 Questions

Who developed the C language in the 1970s?

Dennis Ritchie at Bell Telephone Laboratories, Inc.

What is the purpose of the American National Institute of Standards (ANSI) in relation to the C language?

To develop a standardized definition of the C language

What is essential to study for the final exam in terms of pointer notation?

Pointer notation and manipulation

What is recommended to practice coding for special cases or concepts that are not well understood?

Functions that take and/or return pointers and function calls that have pointers as arguments

What is a good way to review code for the final exam?

Look over code you wrote that works for labs and projects and explain to yourself why it works

What is not a recommended topic to study for the final exam?

Memory management in Java

What is the purpose of the lowercase 'l' flag in a Makefile?

To link libraries into the executable

What is the effect of the '-n' flag when running the command 'make -f Makefile -n'?

It displays the commands but does not create the executable

What is the purpose of the 'clean' target in a Makefile?

To remove the executable

What is the minimum command required to create a tarfile?

tar cf.tar

What is the purpose of the 'v' flag in the 'tar' command?

To show the progress

What is the function of the 'fgets' function in C?

To get a string from the specified stream

What flag is used to enable debugging in the gcc compiler?

-g

What is the purpose of the -o flag in the gcc compiler?

To specify the output file name

What is the default name of the executable file if no -o flag is specified?

a.out

What is the purpose of the Make utility?

To automate and manage the compilation process

How do you end a TypeScript file?

Ctrl + D

What character is used for comments in a Makefile?

Study Notes

Introduction to C Programming

  • C was developed in the 1970s by Dennis Ritchie at Bell Telephone Laboratories, Inc.
  • The American National Institute of Standards (ANSI) developed a standardized definition of the C language.

Makefile and Compilation

  • Use I (lowercase L) to link libraries into the executable
  • Use I (capital i) to ignore errors when executing command scripts
  • make command executes the default target in the makefile called ‘Makefile’
  • make clean command removes the executable using the makefile
  • tar cvf.tar creates a tarfile, tar xf.tar extracts a tarfile

Input/Output

  • #include is used for input/output operations
  • fgets gets a string from the specified stream
  • gcc is the compiler used to compile files
  • Important flags: -g for debug, -Wall for printing all warnings, -o for specifying the executable file name, -lm for math library

Compiling Examples

  • gcc -o hello hello.c -lm compiles and links hello.c to executable hello
  • gcc hello.c -o hello -lm is an alternative way to compile and link
  • gcc hello.c compiles and links to a default executable a.out

Makefile Creation

  • A Makefile automates and manages the process of compiling programs
  • Use vi Makefile or vim Makefile to create a Makefile
  • Use # character for comments, and variable names like CC, CFLAGS, LIBS
  • Use $ character before variable names in targets, prerequisites, and recipes

Test your understanding of Makefile basics and GCC compiler flags. Learn about the different flags and options available in GCC compiler, and how to use them effectively in your projects. From debugging to warning messages, this quiz covers it all.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

GCC Quiz
10 questions

GCC Quiz

LuminousShark8753 avatar
LuminousShark8753
GCC Quiz 1
104 questions

GCC Quiz 1

WorkableCliff4965 avatar
WorkableCliff4965
GCC - 03 Oil Embargo - MCQs
26 questions
Use Quizgecko on...
Browser
Browser