windows中搜索dll的顺序

一般的顺序就是:  exe所在目录--> 当前目录 --> windows system 目录 -->   windows 目录  --> $PATH变量所规定的路径

具体的描述可以参看这里: windows MSDN   。 

If SafeDllSearchMode is enabled, the search order is as follows:

  1. The directory from which the application loaded.
  2. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  3. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  5. The current directory.
  6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

而linux中的搜索路径一般为: 首先 编译链接中的 -L参数, 然后是检查$LD_LIBRARY 路径, 如果还未发现,就会检查/etc/ld.so.conf当中设定的库的路径,

最后是检查 --->   /lib   -->  /usr/lib 或者下的默认库;