【发布时间】:2012-08-16 18:32:38
【问题描述】:
我有 main.c、snmpy.c、snmpy.o 和一个 makefile。我通过命令行在 Linux 服务器上运行它。以下是它们的全部内容...
main.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "snmpy.h"
int main(void) {
char* message = sayHello();
printf("%s", message);
return 0;
}
snmpy.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "snmpy.h"
char* sayHello(){
char* hiya = "Hello!!\n";
return hiya;
}
snmpy.h:
char* sayHello();
制作文件:
# Compiler
CC = /usr/bin/gcc
# Name of program
PROG = snmpy
# The name of the object files
OBJS = snmpy.o main.o
# All the header and c files
SRCS = main.c snmpy.c
HDRS = snmpy.h
# Add -I to the dir the curl include files are in
CFLAGS = -c -g -std=c99 -Wall
# Build the executable file
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(PROG)
# Seperately compile each .c file
main.o: main.c snmpy.h
$(CC) $(CFLAGS) -c main.c
snmpy.o: snmpy.c snmpy.h
$(CC) $(CFLAGS) -c snmpy.c
# Clean up crew
clean:
rm -fv core* $(PROG) $(OBJS)
cleaner: clean
rm -fv #* *~
当我编译它时,它给了我这个错误:
/usr/bin/gcc -c -g -std=c99 -Wall snmpy.o main.o -o snmpy
gcc: snmpy.o: linker input file unused because linking not done
gcc: main.o: linker input file unused because linking not done
不确定是我做错了什么,还是我没有安装什么。我是制作文件的菜鸟。我有一段时间没做过了。
提前致谢!!
【问题讨论】: