Is it a header file or library? in a makefile

Posted by gccinac on Stack Overflow See other posts from Stack Overflow or by gccinac
Published on 2010-06-02T11:55:08Z Indexed on 2010/06/02 12:44 UTC
Read the original article Hit count: 158

Filed under:
|
|

I already know the differences between a header file and a library. However, when I'm writing my makefile, I have some difficulties on deciding if I should put something as a dependency of the file or just at the linking rule.

For example: I have 2 simple files: main.c:

#include <stdio.h>
main(){
  printf("this is the sine or 90");
  sinus(90);
}

and func.c:

#include <math.h>
sinus(int num){
  return sin(num);
}

and my makefile is:

main:   main.o  func.o
    gcc main.o func.o -lm -o main

func.o: func.c
main.o: main.c

Well, my question is why this makefile works and this one doesn't:

main:   main.o  func.o
    gcc main.o func.o -lm -o main

func.o: func.c math.h
main.o: main.c

© Stack Overflow or respective owner

Related posts about c

    Related posts about makefile