Fix --disable-shared

Fixes #3852