Debugging load time error in C++ SDL2 program compiled with VS2015 on Win10

前端 未结 3 2138
无人共我
无人共我 2021-01-11 22:13

I\'m writing a project in C++ with SDL2 on 64-bit Windows 10 using Visual Studio 2015. I recently purchased a new Windows 10 laptop and cloned my project from github. My pro

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-11 22:50

    This is by no means completely reliable, but you can give it a try. It requires dumpbin.exe, which is included with Visual Studio.

    First, get a list of dependent DLLs for your program, resolved against your path:

    del dlls.txt
    for /f %d in ('dumpbin /dependents Questless.exe ^| findstr /ic:".dll"') do @echo %~$PATH:d >> dlls.txt
    

    Then get the bitness of each:

    for /f "delims=" %d in (dlls.txt) do @echo %d & dumpbin /headers "%d" | findstr /c:"machine (x"
    

    This will produce output like:

    C:\Windows\System32\kernel32.dll
                8664 machine (x64)
    C:\programs\ed23\bin\hydra.dll
                 14C machine (x86)
    

    Note that this is incorrectly using the kernel32.dll from System32, rather than the WOW6432 one, so it shows that as x64. That's because it just used the path, when the Windows loader will actually use the WOW6432 mapper, SxS, the application manifest, and only fall back on the path if none of those resolve the dependency. It also doesn't find dependents of dependents (you could script recursing through the dependents, but be sure to filter out duplicates), and of course doesn't know anything about run-time explicit dynamic loads.

    Nevertheless, it's a quick way to get a short list to check, and might identify your problem.

提交回复
热议问题