running threaded tasks in dynamically linked objects from a non-threaded app

John E Hein jhein at
Sun Mar 2 17:18:49 UTC 2008

I am having some issues with an application that uses...
  [1] perl to run test scripts
  [2] with eventually call modules in C modules
  [3] which link with a lib that contains pthread* references.

When the tests run, one gets undefined references to pthread calls
from the run-time linker.

[1] the perl port was not built WITH_THREADS=yes (non-threaded
    is the default)
[3] this lib was built with -pthread, but this does not contain
    an explicit dependency on any threading library.  That's
    how our -pthread works (so one can decide at the time an
    application is linked which threading lib to use)

 - LD_PRELOAD=/usr/lib/ (or if desired)
 - require perl to be built WITH_THREADS=yes for
   users of this application
 - build the lib in [3] with -lthr or -lpthread.  This
   can break if perl in built WITH_THREADS=yes and
   the threading libs in [1] and [3] don't match.

These all have weaknesses in one facet or another.
Are there any different solutions?

More information about the freebsd-threads mailing list