Sunday, 26 May 2013

LoadLibrary and statically linked libraries

LoadLibrary and statically linked libraries

I have read the default search order for dll's on Windows at Dynamic-Link Library Search Order and I think I understand all of the items mentioned there.
My experience shows, that if an application loads a dll using LoadLibrary, any dll that's located in the same folder as the dll the applications loaded explicitly gets also loaded, if statically linked by that dll.
Say, folder F is not in any of the path's in the default search order and I place two dll's A and B into that folder. Dll A is statically linked to dll B (hence will require dll B in order to load into the process). When the application calls LoadLibrary to load A, then B will also be found and loaded without a problem.
I don't, but would like to understand, if this behaviour falls under one of the 6 items in the search order, or is the result from the application setting an additional path on the search order (SetDllDirectory). Which I think is unlikely btw. since that function is only supported since WinXP SP1.
The applications from which I know this behaviour: Matlab, ADAMS, MotionSolve.

No comments:

Post a Comment