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

来源:互联网 发布:美国 大数据公司 data 编辑:程序博客网 时间:2024/06/06 19:00

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 

过程中报错及解决办法:

[html] view plain copy
  1. </pre><pre name="code" class="html">[root@Day magent]# cd magent/  
  2. [root@Day magent]# tar -zxvf magent-0.6.tar.gz   
  3. [root@Day magent]# /sbin/ldconfig   
  4. [root@Day magent]#  sed -i "s#LIBS=-levent#LIBS=-levent -lm#g" Makefile   
  5. [root@Day magent]# make  
  6. gcc -Wall -O2 -g  -c -o magent.o magent.c  
  7. magent.c:64:19: error: event.h: No such file or directory  
  8. magent.c:123: error: field ‘ev’ has incomplete type  
  9. magent.c:153: error: field ‘ev’ has incomplete type  
  10. magent.c: In function ‘server_free’:  
  11. magent.c:467: warning: implicit declaration of function ‘event_del’  
  12. magent.c: In function ‘put_server_into_pool’:  
  13. magent.c:521: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’   
  14. magent.c: In function ‘writev_list’:  
  15. magent.c:623: error: ‘SSIZE_MAX’ undeclared (first use in this function)  
  16. magent.c:623: error: (Each undeclared identifier is reported only once  
  17. magent.c:623: error: for each function it appears in.)  
  18. magent.c: In function ‘out_string’:  
  19. magent.c:695: error: ‘EV_WRITE’ undeclared (first use in this function)  
  20. magent.c:698: warning: implicit declaration of function ‘event_set’  
  21. magent.c:698: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  22. magent.c:699: warning: implicit declaration of function ‘event_add’  
  23. magent.c: In function ‘do_transcation’:  
  24. magent.c:815: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’   
  25. magent.c:817: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  26. magent.c:817: error: ‘EV_WRITE’ undeclared (first use in this function)  
  27. magent.c: In function ‘start_backup_transcation’:  
  28. magent.c:901: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’   
  29. magent.c:903: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  30. magent.c:903: error: ‘EV_WRITE’ undeclared (first use in this function)  
  31. magent.c: In function ‘try_backup_server’:  
  32. magent.c:993: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’   
  33. magent.c:995: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  34. magent.c:995: error: ‘EV_WRITE’ undeclared (first use in this function)  
  35. magent.c: In function ‘drive_memcached_server’:  
  36. magent.c:1013: error: ‘EV_WRITE’ undeclared (first use in this function)  
  37. magent.c:1059: error: ‘EV_READ’ undeclared (first use in this function)  
  38. magent.c:1061: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  39. magent.c: In function ‘process_get_response’:  
  40. magent.c:1235: error: ‘EV_WRITE’ undeclared (first use in this function)  
  41. magent.c:1237: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  42. magent.c: In function ‘process_update_response’:  
  43. magent.c:1282: error: ‘EV_WRITE’ undeclared (first use in this function)  
  44. magent.c:1284: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  45. magent.c: In function ‘drive_backup_server’:  
  46. magent.c:1304: error: ‘EV_WRITE’ undeclared (first use in this function)  
  47. magent.c:1342: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  48. magent.c:1342: error: ‘EV_READ’ undeclared (first use in this function)  
  49. magent.c: In function ‘drive_client’:  
  50. magent.c:1617: error: ‘EV_READ’ undeclared (first use in this function)  
  51. magent.c:1668: error: ‘EV_WRITE’ undeclared (first use in this function)  
  52. magent.c:1681: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  53. magent.c: In function ‘server_accept’:  
  54. magent.c:1733: error: invalid application of ‘sizeof’ to incomplete type ‘struct event’   
  55. magent.c:1734: error: ‘EV_READ’ undeclared (first use in this function)  
  56. magent.c:1734: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  57. magent.c: In function ‘main’:  
  58. magent.c:2105: warning: implicit declaration of function ‘event_init’  
  59. magent.c:2110: error: ‘EV_READ’ undeclared (first use in this function)  
  60. magent.c:2110: error: ‘EV_PERSIST’ undeclared (first use in this function)  
  61. magent.c:2120: warning: implicit declaration of function ‘event_loop’  
  62. make: *** [magent.o] Error 1  

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

[html] view plain copy
  1. [root@Day ~]# find / -name event.h  
  2. /usr/src/kernels/2.6.32-358.el6.x86_64/include/config/acpi/proc/event.h  
  3. /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尽量要用编译安装的方式安装,以避免不必要的麻烦和错误。)

[html] view plain copy
  1. [root@Day Packages]# find / -name event.h  
  2. /usr/local/libevent/include/event2/event.h  
  3. /usr/local/libevent/event.h  
  4. /usr/local/include/event2/event.h  
  5. /usr/local/include/event.h  
  6. /usr/src/kernels/2.6.32-358.el6.x86_64/include/config/acpi/proc/event.h  
  7. /usr/src/kernels/2.6.32-358.el6.x86_64/include/config/kprobe/event.h  

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

解决办法:

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


在这里,推荐参考:

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

阅读全文
0 0
原创粉丝点击