2

私はスタックオーバーフローが初めてです。私は現在、簡単な問題を解決するのに苦労しています。

私のshell/ディレクトリには、次のものがあります。

CVS/
include/
Makefile
obj
src

私の問題は、オブジェクトファイルをビルドするように指示しようとしたときに発生しますが、次のコードでobj実行すると:make

# Beginning of Makefile
OBJS = obj/shutil.o obj/parser.o obj/sshell.o
HEADER_FILES = include/shell.h include/parser.h
EXECUTABLE = simpleshell
CFLAGS = -Wall
CC = gcc
# End of configuration options

#What needs to be built to make all files and dependencies
all: $(EXECUTABLE)

#Create the main executable
$(EXECUTABLE): $(OBJS)
         $(CC) -o $(EXECUTABLE) $(OBJS)

#Recursively build object files
%.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $<

#Define dependencies for objects based on header files
#We are overly conservative here, parser.o should depend on parser.h only
$(OBJS) : $(HEADER_FILES)

clean:
        -rm -f $(EXECUTABLE) obj/*.o
run: $(EXECUTABLE)
        ./$(EXECUTABLE)

tarball:
         -rm -f $(EXECUTABLE) obj/*.o
         (cd .. ; tar czf Kevin_Fairchild_a3.tar.z shell )

# End of Makefile

次のエラーが表示されます。

gcc -o simpleshell obj/shutil.o obj/parser.o obj/sshell.o
gcc: obj/shutil.o: No such file or directory
gcc: obj/parser.o: No such file or directory
gcc: obj/sshell.o: No such file or directory
gcc: no input files
make: *** [simpleshell] Error 1

私が欠けている単純な部分は何ですか?Makefile については、引き続き調査と学習を続けます。

4

2 に答える 2

0

ここに投稿する前に最初に試みた単純な変更を追加した後、つまり

obj/%.o: src/%.c 

このエラーを受け取ったので、もともとは別のものだと思っていました。

gcc -Wall -c -o obj/shutil.o 
src/shutil.c
src/shutil.c:14:19: error: shell.h: No such file or directory
src/shutil.c: In function ‘signal_c_init’:
src/shutil.c:72: error: ‘waitchildren’ undeclared (first use in this function)
src/shutil.c:72: error: (Each undeclared identifier is reported only once
src/shutil.c:72: error: for each function it appears in.)
src/shutil.c: In function ‘checkbackground’:
src/shutil.c:90: warning: implicit declaration of function ‘striptrailingchar’
src/shutil.c: At top level:
src/shutil.c:101: warning: conflicting types for ‘striptrailingchar’
src/shutil.c:90: note: previous implicit declaration of ‘striptrailingchar’ was here
make: *** [obj/shutil.o] Error 1` 

ところで、迅速な返信をありがとう!

于 2013-10-21T20:30:28.727 に答える