linux - 在 dlopen(NULL) 返回的句柄上调用 dlclose

标签 linux shared-libraries

我正在使用 dlopen(NULL) 获取我的可执行文件的主模块的句柄,如下所示。

void *handle = dlopen(NULL, RTLD_NOW);

我应该调用 dlclose(handle) 来减少主模块的引用计数吗?

最佳答案

来自手册页:

   dlclose()
       The  function  dlclose()  decrements the reference count on the dynamic
       library handle handle.  If the reference count drops  to  zero  and  no
       other  loaded  libraries use symbols in it, then the dynamic library is
       unloaded.

我敢打赌,当您将它称为“主”句柄时它是空的

关于linux - 在 dlopen(NULL) 返回的句柄上调用 dlclose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40676660/

相关文章:

c++ - 将对象指针(之前创建的)传递给动态共享库的 extern "C"函数

gcc - 带有 undefined symbol 的静态库?

android - adb pull 在 bash 脚本中的奇怪行为

linux - 非阻塞连接调用不返回连接被拒绝

java - 从 java 中查找 linux 发行版的名称

linux - gcc:错误:选项 ‘-mabi=aapcs-linux’中无法识别的参数

c - 内存和静态/共享库中的程序位置

C++ Linux 如何使用 libtar

postgresql - 共享对象 (.so) 文件 postgresql 的权限被拒绝

linux - 为什么我应该仅仅为了库更新而重新编译整个程序?