Makefile 초보자 질문드립니다.

tlswldnjs410의 이미지

안녕하세요, 간단한 코드인 것 같은데 makefile 을 처음 사용해보는지라
검색 끝에 이렇게 질문하게 되었습니다.
자꾸 undefined reference to `main' 라는 오류가 뜨는데 어떻게 해결해야 할까요?
아래는 코드입니다.

 
//main 함수
#include "Header.h"
 
void main() {
	int arr,res[10],t;
	scanf("%d",&t);
    	for(int i=0;i<t;i++){
        	scanf("%d",&arr);
        	count(arr);
        	output();
    	}
 
}

 
//output.c 함수
#include "Header.h"
 
void output(){
    int res[10];
    for(int i = 0;i < 10; i++){
        printf("%d ",res[i]);
    }
    printf("\n");
}

 
//count.c 함수
#include "Header.h"
 
void count(int arr){
	int res[10];
    for(int i=0;i<10;i++){
        res[i] = 0;
    }
 
    for(int i=1;i<=arr;i++){
        int n = i;
        while(n != 0){
            int m = n % 10;
            n /= 10;
            res[m]++;
        }
    }
}

//Makefile
cc = gcc
cflags = -g
target = main
 
objects = main.o count.o output.o
 
$(target):$(objects)
        $(cc) $(cflags) -o $(targets) $(objects)
 
%.o : %.c
        $(cc) $(cflags) -c -o $@ $<
 
main.o count.o output.o : Header.h
 
.PHONY : clean
clean:
        rm $(target) $(objects) ~             

//Header.h 파일
#include <stdio.h>
#include <stdlib.h>
 
void count(int arr);
void output();

ymir의 이미지

-        $(cc) $(cflags) -o $(targets) $(objects)
+        $(cc) $(cflags) -o $(target) $(objects)
or
-        $(cc) $(cflags) -o $(targets) $(objects)
+        $(cc) $(cflags) -o $@ $(objects)

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

tlswldnjs410의 이미지

우와 진짜 감사해요,,, 저 어제도 이거때문에 5시간 밤새고 정말 힘들었는데 너무 감사합니다!