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 );
}
When I attempt to compile manipulate5.c
with following command:
gcc -I ../include manipulate5.c`
when in directory src
, I get the following error:
In function main:
manipulate5.c:(.text+0x2b): undefined reference to change
So how do I get manipulate5.c
to properly work?