For those running into the same issue on Windows under MSYS2 (using the GCC Suite to compile a shared library, linking an executable to that library, and then finding that dependencies are missing at runtime) you can,
- copy the shared library to the same directory as the executable.
- link to the shared library from the same directory as the executable.
- modify the path environment variable to include the directory that contains the shared library.
MSYS2 may provide a Unix-like environment on Windows, but we still need to adhere to the way in which Windows searches for executables (including shared libraries) at runtime (in short, LD_LIBRARY_PATH is meaningless and the linker does not care about paths supplied with rpath; PATH should be used).