I have 3 directories, src
, lib
, and include
. In include
I have header file header3.h
. Its code is as follows:
//header3.h
extern void change(int *a);
In lib
I have file change4.c
, which contains:
//change4.c
#include <stdlib.h>
#include "header3.h"
void change(int *a){
int y=100;
*a=y;
}
In src
I have file manipulate5.c
, which contains:
//manipulate5.c
#include <stdio.h>
#include "header3.h"
int main(void){
int x=10;
printf("x is %d\n", x );
change(&x);
printf("x is now %d\n", x );
}
I have created object files manipulate5.o
and change4.o
for files manipulate5.c
and change4.c
respectively. How do I link the two when manipulate5.o
is in src
and change4.o
is in lib
?
I should further clarify; I am supposed to be able to run the executable when in the src
directory. Thus, I am not allowed to do the compiling in the root directory.