dlopen/dlclose issue

Alexander Smirnov Alexander.Smirnov@siemens.com
Thu Aug 23 10:57:00 GMT 2012


Hi all,

I've faced with problem and spent too much to find a solution, but 
without success. So hope, somebody can advise me here, thanks in advance.

1. My demo application:
I wrote simple shared object with one function which prints something to 
the screen. I compiled it by: gcc -shared -o libtest.so test.c

In other file I opened this library by 'dlopen(..., RTLD_LAZY)'. Than 
found sym by dlsym, executed it and called dlclose.

2. After 'dlclose' I executed dlopen(..., RTLD_LAZY | RTLD_NOLOAD) and 
it returned non-zero value. So the library is still in use!

3. If I call dlclose twice, the point 2 returns 0.


What is the proper way to check if some library loaded/unloaded? Why do 
I need to call dlclose twice? Why in some applications 
'while(dlclose(...) == 0);' loop can be infinite?


-- 
With best regards,
Alexander Smirnov



More information about the Gcc-help mailing list