首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译csapp.c和csapp.h

编译csapp.c和csapp.h
EN

Stack Overflow用户
提问于 2012-06-16 11:01:13
回答 1查看 3.1K关注 0票数 0

我正在尝试在Ubuntu12操作系统上编译csapp.ccsapp.h文件。我想我遗漏了一些头文件或一些选项,但我不知道是哪一个。或许我没有最新的gcc。这是我的Makefile:

代码语言:javascript
复制
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)

以下是我从终端输出的错误:

代码语言:javascript
复制
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

下面是我的main函数中的最后一个剩余错误:

代码语言:javascript
复制
tiny.c:23:24: error: storage size of ‘clientaddr’ isn’t known

下面是我的代码的第23行:

代码语言:javascript
复制
 struct socketaddr_in clientaddr;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-16 12:14:49

使用-std=gnu99,请参阅此link。我为你写了一个新的Makefile,希望能对你有所帮助。

代码语言:javascript
复制
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
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11060434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档