V
vijay
I am trying to learn C and am struck at header file stuff. I have the
following source files in my directory:
header.h
------------
int a_function(int);
library.c
-----------
#include "header.h"
int a_function(int x) {
return x + 1;
}
program.c
--------------
#include "header.h"
#include <stdio.h>
main() {
printf("%d", a_function(4));
}
Now when I try
gcc -o program program.c, I get
/tmp/cciTe17G.o(.text+0x19): In function `main':
: undefined reference to `a_function'
collect2: ld returned 1 exit status
In fact, I had not expected it to work but I really don't know what I
need to do fix this.
following source files in my directory:
header.h
------------
int a_function(int);
library.c
-----------
#include "header.h"
int a_function(int x) {
return x + 1;
}
program.c
--------------
#include "header.h"
#include <stdio.h>
main() {
printf("%d", a_function(4));
}
Now when I try
gcc -o program program.c, I get
/tmp/cciTe17G.o(.text+0x19): In function `main':
: undefined reference to `a_function'
collect2: ld returned 1 exit status
In fact, I had not expected it to work but I really don't know what I
need to do fix this.