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();
makefile:
# 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
私が正しくやっていないことがあるのか、それとも何かをインストールしなかったのか、何が起こっているのかわかりません。私はmakeファイルの作成に不慣れです。私はしばらくそれらをしていません。
前もって感謝します!!