Fix cross-compiling between i686 and x86_64 when building SHARED lib.
Credits goes to alexrass.