linux动态链接库的使用

编译一个晚上学到的:linux下加载和调用动态链接库的一个方法。 #include<dlfcn.h> #include<stdio.h> int main(int argc, char *argv[]) { void *libc; void (*printf_call)(); if(libc = dlopen("libc.so.6", RTLD_LAZY)) // RTLD_LAZY表示函数的惰性邦定 { printf_call = dlsym(libc, "printf"); (*printf_call)("hello, world\n"); dlclose(libc); } return 0; } ===================== 编译: gcc -ldl test_hook.c -o test
原文地址:https://www.cnblogs.com/ohscar/p/3109624.html