magent编译报错error: event.h: No such file or directory

magent编译安装整理:

# tar zxvf magent-0.5.tar.gz  
# /sbin/ldconfig  
# sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile  
# make  
# cp magent /usr/bin/magent 

过程中报错及解决办法:

</pre><pre name="code" class="html">[root@Day magent]# cd magent/
[root@Day magent]# tar -zxvf magent-0.6.tar.gz 
[root@Day magent]# /sbin/ldconfig 
[root@Day magent]#  sed -i "s#LIBS=-levent#LIBS=-levent -lm#g" Makefile 
[root@Day magent]# make
gcc -Wall -O2 -g  -c -o magent.o magent.c
magent.c:64:19: error: event.h: No such file or directory
magent.c:123: error: field ‘ev’ has incomplete type
magent.c:153: error: field ‘ev’ has incomplete type
magent.c: In function ‘server_free’:
magent.c:467: warning: implicit declaration of function ‘event_del’
magent.c: In function ‘put_server_into_pool’:
magent.c:521: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’ 
magent.c: In function ‘writev_list’:
magent.c:623: error: ‘SSIZE_MAX’ undeclared (first use in this function)
magent.c:623: error: (Each undeclared identifier is reported only once
magent.c:623: error: for each function it appears in.)
magent.c: In function ‘out_string’:
magent.c:695: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c:698: warning: implicit declaration of function ‘event_set’
magent.c:698: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c:699: warning: implicit declaration of function ‘event_add’
magent.c: In function ‘do_transcation’:
magent.c:815: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’ 
magent.c:817: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c:817: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c: In function ‘start_backup_transcation’:
magent.c:901: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’ 
magent.c:903: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c:903: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c: In function ‘try_backup_server’:
magent.c:993: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’ 
magent.c:995: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c:995: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c: In function ‘drive_memcached_server’:
magent.c:1013: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c:1059: error: ‘EV_READ’ undeclared (first use in this function)
magent.c:1061: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c: In function ‘process_get_response’:
magent.c:1235: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c:1237: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c: In function ‘process_update_response’:
magent.c:1282: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c:1284: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c: In function ‘drive_backup_server’:
magent.c:1304: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c:1342: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c:1342: error: ‘EV_READ’ undeclared (first use in this function)
magent.c: In function ‘drive_client’:
magent.c:1617: error: ‘EV_READ’ undeclared (first use in this function)
magent.c:1668: error: ‘EV_WRITE’ undeclared (first use in this function)
magent.c:1681: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c: In function ‘server_accept’:
magent.c:1733: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’ 
magent.c:1734: error: ‘EV_READ’ undeclared (first use in this function)
magent.c:1734: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c: In function ‘main’:
magent.c:2105: warning: implicit declaration of function ‘event_init’
magent.c:2110: error: ‘EV_READ’ undeclared (first use in this function)
magent.c:2110: error: ‘EV_PERSIST’ undeclared (first use in this function)
magent.c:2120: warning: implicit declaration of function ‘event_loop’
make: *** [magent.o] Error 1

分析:起一个error说缺少.h文件,因为我用的libevent是用rpm方式安装的,用 find / -name event.h查找event.h 结果如下:

[root@Day ~]# find / -name event.h
/usr/src/kernels/2.6.32-358.el6.x86_64/include/config/acpi/proc/event.h
/usr/src/kernels/2.6.32-358.el6.x86_64/include/config/kprobe/event.h

该文件没有被包含在/usr/include或者/usr/local/include的头文件目录中,可能是跟rpm方式安装有关系,故改用编译安装libevent,再试,继续make(第一个event.h问题解决,说明libevent尽量要用编译安装的方式安装,以避免不必要的麻烦和错误。)

[root@Day Packages]# find / -name event.h
/usr/local/libevent/include/event2/event.h
/usr/local/libevent/event.h
/usr/local/include/event2/event.h
/usr/local/include/event.h
/usr/src/kernels/2.6.32-358.el6.x86_64/include/config/acpi/proc/event.h
/usr/src/kernels/2.6.32-358.el6.x86_64/include/config/kprobe/event.h

[root@Day magent]# make
gcc -Wall -O2 -g  -c -o magent.o magent.c
magent.c: In function ‘writev_list’:
magent.c:623: error: ‘SSIZE_MAX’ undeclared (first use in this function)
magent.c:623: error: (Each undeclared identifier is reported only once
magent.c:623: error: for each function it appears in.)
make: *** [magent.o] Error 1

解决办法:

vim ./ketama.h 
#在开头加入
#ifndef SSIZE_MAX
#define SSIZE_MAX      32767
#endif
继续make:
[root@Day magent]# make
gcc -Wall -O2 -g  -c -o magent.o magent.c
gcc -Wall -O2 -g  -c -o ketama.o ketama.c
gcc -Wall -O2 -g -o magent magent.o ketama.o -levent -lm
[root@Day magent]# ll
total 332
-rw-r--r--. 1  500  502  12821 Sep 16 14:16 ketama.c
-rw-r--r--. 1  500  502    393 Sep 16 14:17 ketama.h
-rw-r--r--. 1 root root  23520 Sep 16 14:17 ketama.o
-rwxr-xr-x. 1 root root  90746 Sep 16 14:17 magent
-rw-r--r--. 1 root root  16394 Sep 16 13:34 magent-0.5.tar.gz
-rw-r--r--. 1 root root  17257 Sep 16 11:12 magent-0.6.tar.gz
-rw-rw-r--. 1  500  502  48845 Sep 27  2008 magent.c
-rw-r--r--. 1 root root 102848 Sep 16 14:17 magent.o
-rw-rw-r--. 1  500  502    347 Sep 16 13:58 Makefile
[root@Day magent]# 
没有报错,生成了 magent。


在这里,推荐参考:

http://blog.snsgou.com/post-820.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值