Applied patch from fjaeger for static linking