Hi,
Pallavi Kandhare wrote:
> I have 2 files : list1.h and list1.c, and I call some functions defined
> in list1.h in main function of main.c.
First, some definitions:
Functions are generally declared in headers, and defined in C files.
A declaration of any function is required before you can use it.
> list1.h is included in both list1.c and main.c.
So your function is declared in main.c, and should compile OK.
> Still i am getting the following error :
> /test1file/src/main.c undefined reference to function-name
This is a linker error - it means that at the time you are creating the
executable, the definition of the function is not being found.
> The list1.o file is not created. What changes do i need to make to my
> Makefile in order to remove this error.
That all depends on what your Makefile looks like now, doesn't it? ;)
Generally it should resemble this:
all: list1.o main.o
cc -o my_prog list1.o main.o
list1.o:
cc -c list1.c
main.o:
cc -c main.c
(there are ways to make this shorter, using pattern rules).
Cheers,
Dave.
--
maemo.org docsmaster
Email: [email protected]
Jabber: [email protected]
_______________________________________________
maemo-developers mailing list
[email protected]
https://lists.maemo.org/mailman/listinfo/maemo-developers