-
header file including
head.c:
Code:
int add(int a, int b)
{
return(a+b);
}
head.h:
main.c:
Code:
#include "head.h"
main()
{
int a = 10, b = 9;
printf("addition is : %d", add(a+b));
}
=================
gives error:
Code:
/tmp/ccuq5Rod.o: In function `main':
main.c:(.text+0x28): undefined reference to `add'
collect2: ld returned 1 exit status
any line of code needs to be added in any file without changing the file structure/number of files. m unable to make it.
-
There's nothing wrong with the files and everything wrong with your command line.
-
thanx,
but isn't it possible to change code without changing command line without error?
-
That is the way you compile programs with multiple source files.
Sure, you can compile everything in a single source, but it's one hell of a hack.