Is that the best solution for this problem or there's something more elegant?
This is a well-known problem called "DLL hell". The safest solution is to keep all libraries you need in the same directory as the executable, but of course it ruins the whole concept of shared libraries.
Bookmarks