libev库安装:
1.下载页面:
当前版本下载:
[root@mid_server ~]# cd /usr/local/src
[root@mid_server src]# wget
2.解压以及安装:
[root@mid_server src]# tar -zxvf libev-4.20.tar.gz
[root@mid_server src]# cd libev-4.20
[root@mid_server libev-4.20]# ./configure
[root@mid_server libev-4.20]# echo $?
[root@mid_server libev-4.20]# make
[root@mid_server libev-4.20]# make install
gcc下编译含libev库函数的c文件test.c:
[root@mid_server src]# gcc test4.c -lev
没有报错,就行。
若不加-lev:
[root@mid_server src]# gcc test4.c
/tmp/ccCIrnLe.o: In function `io_action':test4.c:(.text+0x74): undefined reference to `ev_io_stop'/tmp/ccCIrnLe.o: In function `main':test4.c:(.text+0x93): undefined reference to `ev_default_loop'test4.c:(.text+0x108): undefined reference to `ev_io_start'test4.c:(.text+0x11c): undefined reference to `ev_run'collect2: ld 返回 1 eclipse下添加需要链接的库:
Project -> Properties -> C/C++ Build -> Settings里面的Libraries -> 在Libraries(-l)里面点击+(添加按钮),写入ev,保存退出,代码就不报错了!