Libevent库静态编译方法

1. 首先通过configure设置关闭动态编译,打开静态编译
./configure –disable-shared –enable-static

可以比较默认编译选项和做如上设置的编译后的文件大小比较,
sample目录下,静态编译的可执行文件使用strip后,http-server 为140kb,动态库方式的为20kb左右.

2. 在链接时要添加 -lrt 这个库,否则会提示缺少函数符号clock_gettime
gcc testev.c -I../libevent/include/ -levent -L ../libevent/lib/ -lrt

Popularity: 8% [?]

Random Posts

Comments

Comments are closed.