Hello,
I am trying to use make to compile and link two simple C programs in linux. Here is the two programs.
combine1.c
combine2.cCode://combine1.c #include <stdio.h> int main(void) { int n; printf("This is a test\n"); printf("n=%d\n", input(n)); printf("Done"); return 0; }I can compile and link these two using gcc without any trouble:Code://combine2.c input(int n) { n = 10; return n; }
I want to compile and link the two using make but I don't think I am doing my Makefile correctly. Can someone explain how to do this? Here is what I have for my Makefile:Code:gcc -o combine combine1.c combine2.c
When I type $makeCode:project1: combine1.o gcc -o project1 combine1.o combine1.o: combine1.c combine2.c gcc -c combine1.c clean: rm project1 combine1.o
I get the following:
Thanks for any help.Code:combine1.o: In function `main': combine1.c:(.text+0x1b): undefined reference to `input' collect2: ld returned 1 exit status make: *** [project1] Error 1

