Changing Windows DLL load order? (load order, not search order)

前端 未结 4 1432
半阙折子戏
半阙折子戏 2021-02-07 11:15

Say I have one executable: app.exe

I use 2 different 3rd party DLLs in this executable: foo.dll bar.dll and the Application must l

4条回答
  •  情歌与酒
    2021-02-07 12:16

    What I haven't found out yet is how to influence this load order ...

    I have no clue why I hadn't tried this, but it seems the import section order of the resulting module does depend on the order in which the lib files are provided to the linker.

    Configuration Properties -> Linker -> Additional Dependencies ...
    

    The lib files listed here first are also first in the import section, meaning the loader will import these in order (modulo dependencies).

    So, to answer that part: Just provide the lib files in the correct order to the linker.

    Note: I have tried that on VS2005 and it appears to work. I don't know whether that is documented somewhere or if it changed in newer versions of VC++.


    Update: While it worked back then, today I hit the case that the load order was not to be influenced by the linker command line order of the lib files. (Still) No clue why. (Still VS2005)

    I have however managed to make it work by adding the problematic DLLs to the list of delay loaded DLLs (like in Macke's answer).


提交回复
热议问题