about c - chris-wangkk/myWiki GitHub Wiki
#动态库
1.编译 gcc -fPIC -shared *.c -o lib*.so
2.使用(详见在linux上man dlopen)
#include
void *dlopen(const char *filename, int flag);
以指定模式打开指定的动态连接库文件,并返回一个句柄给调用进程
关于打开模式:
RTLD_LAZY 暂缓决定,等有需要时再解出符号
RTLD_NOW 立即决定,返回前解除所有未决定的符号
char *dlerror(void);
返回出现的错误
void *dlsym(void *handle, const char *symbol);
通过句柄和连接符名称获取函数名或者变量名
int dlclose(void *handle);
卸载打开的库