Make Error: Undefined symbols for architecture x86_64:

Make Error: Undefined symbols for architecture x86_64:

我刚开始用 C 编程,并决定使用 make 来构建我的示例应用程序。使用 GCC 命令编译文件工作正常,但是,使用 make 失败并出现错误。如果 make 只是在后台执行 gcc 命令,我不明白为什么这是可能的。

文件列表如下:

makefile.make:

app.o: app.c helper.h
    gcc -c app.c

helper.o: helper.h helper.c
    gcc -c helper.c

app: app.o helper.o
    gcc app.o helper.o -o app

app.c

/*
 * file: app.c
 */
#include "helper.h"

int main() {
    do_something();
    return 0;
}

helper.h

/*
 * helper.h
 */
void do_something();

helper.c

/*
 * file: helper.c
 */
#include <stdio.h>
#include "helper.h"

void do_something() {
    printf("Test\n");
    printf("Testsss\n");
}

问题:运行 "make app" 抛出错误信息

Undefined symbols for architecture x86_64:
  "_do_something", referenced from:
      _main in app.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [app] Error 1

我尝试过的有效方法:

将 "makefile.make" 重命名为 "makefile" 或 "Makefile"。 "app.o" 和 "helper.o" 似乎有效,但我认为这只是在执行其默认说明。