Fix dependencies and compile with -fPIC if building shared library.