Question: For this section consider the following files: / * libfile 1 . h * / int byn ( int a , int n ) ;

For this section consider the following files:
/* libfile1.h */
int byn(int a, int n);
---
/* libfile2.h */
int by2(int a);
---
/* libfile1.cxx */
#include "libfile1.h"
int byn(int a, int n){ return a*n; }
---
/* libfile2.cxx */
#include "libfile1.h"
#include "libfile2.h"
int by2(int a){ return byn(a,2); }
int by3(int a){ return byn(a,3); }
Q2. It is desired combine the code in the above files into a static library (or archive).
(a) Which files need to be compiled? [4]
(b) Give the C++ compiler command which converts the source file to an object
file. [2]
(c) State the dependencies of each cxx file. [6]
(d) Using make syntax, write down the dependencies and action which will result
in the production of libfile1.o.[5]
(e) libfile1.h contains only the prototype of the byn function. Why is it included
by libfile1.cxx where the function is defined? [2]
(f) Describe a process by which header-file dependencies can be generated automatically as compilation progresses. You do not need to give specific commands
to achieve each step you describe.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!