@Sid, am I right to assume that the problem with statics only occurs with the use of shared libraries, but not with the use of static libraries? Also, I have no clue what your second snippet does.
@Michael, I think I see what you did there, nice workaround. @fog, that's not a snippet.