After cross-compiling your project for Windows, you find that it crashes due to missing DLLs. I will show how to identify any required DLLs using objdump, and copy them to your build directory.
mingw32-objdump can be used to analysis an executable or object. Among other
things, it lists the .DLLs which are required by the .EXE. Call it by passing
the path to the executable and the
This will output a ton of content, so you’ll want to pass the result through grep and sed to get just the DLL names:
The output will look a bit like this:
libgcc_s_seh-1.dll KERNEL32.dll msvcrt.dll libwinpthread-1.dll libstdc++-6.dll WSOCK32.dll sfgui.dll sfml-graphics-2.dll sfml-network-2.dll sfml-system-2.dll sfml-window-2.dll libthor.dll
Now we want to iterate over the result of this, and try and find the DLL in a number of search paths. Here’s the full script to do that:
The output will look like this:
Found libgcc_s_seh-1.dll in /usr/x86_64-w64-mingw32/bin Unable to find KERNEL32.dll Unable to find msvcrt.dll Found libwinpthread-1.dll in /usr/x86_64-w64-mingw32/bin Found libstdc++-6.dll in /usr/x86_64-w64-mingw32/bin Unable to find WSOCK32.dll Found sfgui.dll in /usr/local/mingw64/bin Found sfml-graphics-2.dll in /usr/local/mingw64/bin Found sfml-network-2.dll in /usr/local/mingw64/bin Found sfml-system-2.dll in /usr/local/mingw64/bin Found sfml-window-2.dll in /usr/local/mingw64/bin Found libthor.dll in /usr/local/mingw64/bin
Some DLLs won’t be found as they’re provided as part of Windows.