gpt4 book ai didi

c++ - dlclose 无法关闭共享库

转载 作者:太空宇宙 更新时间:2023-11-04 09:50:02 24 4
gpt4 key购买 nike

我在 Linux 中遇到过以下问题。我有一些使用外部库的应用程序(应用程序未与其链接)。我通过 dlopen 打开库并使用其中的一些符号。当我尝试通过 dlclose 卸载库时出现问题,我仍然看到在 /proc/.../maps 中加载了库。

更多关于使用以下内容的尝试:

...
while(dlclose(module) == 0);
...

导致无限循环,库仍在加载。

有什么方法可以检查/找到图书馆的所有者吗?

最佳答案

来自“man 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.

您很可能与“没有其他加载的库使用符号”条款发生冲突。

最好的办法是使用 LD_DEBUG=bindings 运行,并查看哪些其他库绑定(bind)到您要卸载的库。

另见 this问题。

关于c++ - dlclose 无法关闭共享库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12131344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com