This is because the last error was overridden by the subsequent tries.
Maybe we should stop trying once the right file was found. This way the
right message could be given to user.
The trouble is that it is not dlopen that gives this message, it is
dlerror that gives the message, and it would be terrible to use
string comparison to dig out the cause of the failure. And that's
just for the dlopen loader, who knows how the other loaders behave
on obscure systems in wierd corner cases. Finding a reliable way
to catch all errors that are not "file not found" or equivalent
and quit early will not be an easy task.
The loaders typically just report CANNOT_OPEN when something fails,
and the ltdl core has no reliable way of knowing the underlying
cause.