ubuntu下安装libev开发包.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ubuntu下安装libev开发包

ubuntu下安装libev开发包 $ sudo apt-get install libev-dev 将会安装下列额外的软件包: ? libev3 下列【新】软件包将被安装: ? libev-dev libev3 但是由于libev在ubuntu软件库中的版本为3,而最新libev版本已经是4,所以会有不兼容。 下面是libev的man page自带的libev用法示例,保存到testlibev.c: 该示例文件演示了io输入事件和超时事件。 // a single header file is required #include ev.h #include stdio.h // for puts // every watcher type has its own typedef’d struct // with the name ev_TYPE ev_io stdin_watcher; ev_timer timeout_watcher; // all watcher callbacks have a similar signature // this callback is called when data is readable on stdin ??? static void stdin_cb (EV_P_ ev_io *w, int revents) { ??? puts (“stdin ready”); ??? // for one-shot events, one must manually stop the watcher ??? // with its corresponding stop function. ??? ev_io_stop (EV_A_ w); ??? // this causes all nested ev_run’s to stop iterating ??? ev_break (EV_A_ EVBREAK_ALL); } // another callback, this time for a time-out ??? static void timeout_cb (EV_P_ ev_timer *w, int revents) { ??? puts (“timeout”); ??? // this causes the innermost ev_run to stop iterating ??? ev_break (EV_A_ EVBREAK_ONE); } ??? int main (void) { ??? // use the default event loop unless you have special needs ??? struct ev_loop *loop = EV_DEFAULT; ??? // initialise an io watcher, then start it ??? // this one will watch for stdin to become readable ??? ev_io_init (stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); ??? ev_io_start (loop, stdin_watcher); ??? // initialise a timer watcher, then start it ??? // simple non-repeating 5.5 second timeout ??? ev_timer_init (timeout_watcher, timeout_cb, 5.5, 0.); ??? ev_timer_start (loop, timeout_watcher); ??? // now wait for events to arrive ??? ev_run (loop, 0); ??? // unloop was called, so exit ??? return 0; } 编译: 报告 EVBREAK_ONE 等没有定义。 ev_break等没有实现。 此时需到官网下载最新4.01源码。 http://dist.schmorp.de/libev/ 执行./configure,make,make install 编译时头文件查找路径: 先查找-I,在查gcc环境变量 C_INCLUDE_PATH,CPLUS_INCLUDE_PATH,OBJC_INCLUDE_PATH,再查内定目录 /usr/include? /usr/local/include /usr/lib/… 所以gcc能在/usr/local/include中找到最新宏的定义

文档评论(0)

yan698698 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档