0

Ubuntu12オペレーティングシステムでcsapp.cファイルとcsapp.hファイルをコンパイルしようとしています。ヘッダーファイルまたはオプションが不足していると思いますが、どちらかわかりません。または、おそらく私は最新のgccを持っていません。これが私のMakefileです:

SRC = tiny.c
LIB = csapp.c
INC = csapp.h

ALL = $(SRC) $(LIB) $(INC)

webServer-gcc : $(ALL)
    gcc -std=c99 -O2 -lpthread -lrt -o server $(ALL)

ターミナルからのエラー出力は次のとおりです。

csapp.c: In function ‘Kill’:
csapp.c:81:5: warning: implicit declaration of function ‘kill’ [-Wimplicit-function-    declaration]
csapp.c: In function ‘Signal’:
csapp.c:124:22: error: storage size of ‘action’ isn’t known
csapp.c:124:30: error: storage size of ‘old_action’ isn’t known
csapp.c:127:5: warning: implicit declaration of function ‘sigemptyset’ [-Wimplicit-  function-declaration]
csapp.c:128:23: error: ‘SA_RESTART’ undeclared (first use in this function)
csapp.c:128:23: note: each undeclared identifier is reported only once for each    function it appears in
csapp.c:130:5: warning: implicit declaration of function ‘sigaction’ [-Wimplicit-function-declaration]
csapp.c: In function ‘Sigprocmask’:
csapp.c:138:5: warning: implicit declaration of function ‘sigprocmask’ [-Wimplicit-function-declaration]
csapp.c: In function ‘Sigfillset’:
csapp.c:152:5: warning: implicit declaration of function ‘sigfillset’ [-Wimplicit-function-declaration]
csapp.c: In function ‘Sigaddset’:
csapp.c:159:5: warning: implicit declaration of function ‘sigaddset’ [-Wimplicit-function-declaration]
csapp.c: In function ‘Sigdelset’:
csapp.c:166:5: warning: implicit declaration of function ‘sigdelset’ [-Wimplicit-function-declaration]
csapp.c: In function ‘Sigismember’:
csapp.c:174:5: warning: implicit declaration of function ‘sigismember’ [-Wimplicit-function-declaration]
csapp.c: In function ‘Fdopen’:
csapp.c:326:5: warning: implicit declaration of function ‘fdopen’ [-Wimplicit-function-declaration]
csapp.c:326:13: warning: assignment makes pointer from integer without a cast [enabled by default]
csapp.c: In function ‘open_clientfd’:
csapp.c:741:5: warning: implicit declaration of function ‘bzero’ [-Wimplicit-function-declaration]
csapp.c:743:5: warning: implicit declaration of function ‘bcopy’ [-Wimplicit-function-declaration]
make: *** [webServer-gcc] Error 1

これが私のメイン関数内に残っている最後のエラーです:

tiny.c:23:24: error: storage size of ‘clientaddr’ isn’t known

これが私のコードの23行目です。

 struct socketaddr_in clientaddr;
4

1 に答える 1

2

-std=gnu99このリンクを参照してください。そして私はあなたのために新しいものを書きMakefileます、これがあなたを助けることを願っています.

CC = gcc
LIBS = -lpthread  -lrt
INCS = -I./
CCFLAGS = -std=gnu99 -O2

all: server
server: csapp.o tiny.c
        $(CC) $(CCFLAGS) $^ -o $@  $(LIBS) $(INCS)
csapp.o: csapp.c csapp.h
        $(CC) $(CCFLAGS) -c $< -o $@  $(INCS)

clean:
        rm -f server csapp.o
于 2012-06-16T04:14:49.020 に答える