Here is what I believe should be the final set of patches building notmuch as a shared library. Everything seems to work. Let me know if there are any objections. Thanks! - Ben