Fix DLL build

This PR fixes the build process for Windows to correctly use `__declspec(dllexport)` on building the library, but `__declspec(dllimport)` when using the library.
Besides, it sets the default visibility of symbols to "hidden" when building with GCC or Clang, reducing library size and enabling some more compiler optimizations (https://gcc.gnu.org/wiki/Visibility).