libuv学习
libuv
编译安装库
- 源码编译-自动检测生成
./autogen.sh - 源码编译-配置
./configure - 源码编译-编译
make - 源码编译-检查测试项
make check - 安装库
make install
安装到了 /usr/local/lib 下
有如下文件:
-rw-r--r-- 1 root root 1.9M 1月 8 15:29 libuv.a
-rwxr-xr-x 1 root root 931 1月 8 15:29 libuv.la
lrwxrwxrwx 1 root root 14 1月 8 15:29 libuv.so -> libuv.so.1.0.0
lrwxrwxrwx 1 root root 14 1月 8 15:29 libuv.so.1 -> libuv.so.1.0.0
-rwxr-xr-x 1 root root 925K 1月 8 15:29 libuv.so.1.0.0
helloworld
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
int main()
{
uv_loop_t *loop = malloc(sizeof(uv_loop_t)); // 分配内存
printf("%lu");
uv_loop_init(loop);
printf("Now quitting.\n");
uv_run(loop, UV_RUN_DEFAULT);
uv_loop_close(loop); // 必须先关闭,再回收。uv_loop_close(uv_loop_t *)
free(loop);
return 0;
}
libuv的handles和requests
/* Handle types */
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_stream_s uv_stream_t;
typedef struct uv_tcp_s uv_tcp_t;
typedef struct uv_udp_s uv_udp_t;
typedef struct uv_pipe_s uv_pipe_t;
typedef struct uv_tty_s uv_tty_t;
typedef struct uv_poll_s uv_poll_t;
typedef struct uv_timer_s uv_timer_t;
typedef struct uv_prepare_s uv_prepare_t;
typedef struct uv_check_s uv_check_t;
typedef struct
typedef struct
typedef struct
typedef struct
typedef struct
typedef struct

浙公网安备 33010602011771号