13、《Libevent中文帮助文档》学习笔记13:Linux下集成、运行libevent

本文记录了在Linux下集成libevent库时遇到的问题及解决过程。编译安装libevent后,运行依赖libevent的程序时,由于默认搜索路径不包含/usr/local/lib,导致无法找到libevent_core-2.1.so.6库。解决方案是将库文件拷贝到搜索路径或创建软链接。
摘要由CSDN通过智能技术生成

Linux下编译libevent的指导可以参考《4、《Libevent中文帮助文档》学习笔记4:Linux下编译libevent》,完成编译、安装,生成so库后,其他程序即可依赖libevent的so库,使用libevent的功能。

由于没有通过prefix指定安装路径,因此库文件默认安装在/usr/local/lib下,头文件在/usr/local/include下,如下所示:

如图可以看出,libevent的so库存在软链接现象。

集成libevent的源码如下:

/*For sockaddr_in*/
#include <netinet/in.h>
/*For socket functions*/
#include <sys/socket.h>
/*For fcntl*/
#include <fcntl.h>
#include <event2/event.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#define MAX_LINE 16384

void do_read(evutil_socket_t fd, short events, void*arg);
void do_write(evutil_socket_t fd, short events, void*arg);

char rot13_char(char c)
{
    /* We don’t want to use isalpha here; setting the locale change which characters are considered alphabetical.*/
    if ((c >= 'a' && c <= 'm') || (c >= 'A' && c <= 'M'))
    {
        return c + 13;
    }
    else if ((c >= 'n' && c <= 'z') || (c >= 'N' && c <= 'Z'))
    {
        return c - 13;
    }
    else
    {
        return c;
    }
}

struct fd_state
{
    char buffer[MAX_LINE];
    size_t buffer_used;
    size_t n_written;
    size_t write_upto;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值