Makefile 让我很困惑。我要做的就是将一些函数分离到一个单独的文件中,但我无法编译它。我错过了什么?谢谢!
生成文件:
all: clientfunctions client
clientfunctions.o: clientfunctions.c
gcc -c clientfunctions.c -o clientfunctions.o
client.o: client.c clientfunctions.o
gcc -c client.c -o client.o
client: client.o
gcc client.o -o client
.c 和 .h 文件也很简单:
客户端函数.h
#ifndef _clientfunctions_h
#define _clientfunctions_h
#endif
void printmenu();
客户端函数.c
#include <stdio.h>
#include "clientfunctions.h"
void printmenu() {
fprintf(stdout, "Please select one of the following options\n");
}
客户端.c
#include "clientfunctions.h"
int main (int argc, char * argv[])
{
printmenu();
return 0;
}
这是我得到的错误:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [clientfunctions] Error 1