Ubuntu编译生成libevent库

  1. 下载libevent
  2. 配置
    2.1 ./configure --prefix=/usr/lib/libevent
    报错如下

    configure: error: openssl is a must but can not be found. You should add the directory containing `openssl.pc' to the `PKG_CONFIG_PATH' environment variable, or set `CFLAGS' and `LDFLAGS' directly for openssl, or use `--disable-openssl' to disable support for openssl encryption

    2.2 解决方法:
    需要配置环境变量PKG_CONFIG_PATH为openssl.pc的路径,Ubuntu已经装了openssl,但是找不到openssl.pc,原因是没有安装 libssl-dev
    输入命令: sudo apt install -y libssl-dev 后安装后可以找到openssl.pc的路径:/usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc

    2.3 配置环境变量PKG_CONFIG_PATH后,2.1的命令可以执行成功

  3. 编译
    1) make
    2) sudo make install
  4. 查看结果
    ll /usr/lib/libevent
    Ubuntu编译生成libevent库_第1张图片

你可能感兴趣的:(Ubuntu编译生成libevent库)