linux C 加载so文件 指定路径

在Linux C中动态加载.so文件用dlopen("libdemo.so", RTLD_NOW);

但是默认的so搜索目录不包括当前程序目录,所以必须复制到系统的so目录 才能运行 不然就会出现./hook: error while loading shared libraries: libdemo.so: cannot open shared object file: No such file or directory

要解决这个问题 只需要在编译的时候指定-fPIC -rdynamic -Wl,-rpath,./

posted on 2016-07-14 15:37  弘道者  阅读(1574)  评论(0编辑  收藏  举报