2012-08-26 34 views
0

我在Linux中遇到了以下問題。我有一些使用外部庫的應用程序(該應用程序未與其鏈接)。我打開圖書館dlopen並使用它的一些符號。發生這個問題時,我試圖卸載圖書館的dlclose,我仍然看到圖書館加載在/proc/.../maps共享庫無法關閉dlclose

更在嘗試使用以下內容:

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

導致無限循環中,庫仍然加載。

是否有任何方法檢查/查找誰擁有圖書館?

+0

你不應該打擾那麼多。實際上,即使使用數以千計的「dlopen」編輯的共享對象,也不會執行任何'dlclose'。 –

回答

2

從「人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運行,看看哪個庫綁定到你想卸載的庫。

另請參閱this的問題。