Non-threaded app dlopen-ing a thread-using library

Jason Evans jasone at canonware.com
Thu Oct 6 01:55:56 PDT 2005


On Oct 4, 2005, at 11:02 PM, Mikhail Teterin wrote:
> Do I need to make the executable itself multi-threaded -- just in case
> it needs to dlopen() a thread-using library, or is there a better way?
>

As long as the dlopen()ed library is correctly linked, your app  
doesn't need to explicitly link against the library's dependencies.   
Dependencies should get pulled in after dlopen() as necessary, on the  
fly, as a result of the dlopen()ed library's dependencies.

There's nothing magical about a threaded app, as compared to a non- 
threaded app.  The first time a pthreads API is called, libpthread  
initializes itself.  It's fine if this happens as the result of  
executing dlopen()ed code; the only issue is making sure that the  
library dependencies are set up correctly.

Jason



More information about the freebsd-threads mailing list