Problem
When using mingw-64 to compile programs, it usually comes with lots of dlls in dependencies. Moreover, these dlls are placed inside the installation path, inside mingw32/bin
for 32-bit dlls and mingw64/bin
for 64-bit dlls. When I want to share my program with my friends, I usually need to packing the dlls with the exe. So I need to collect the dlls by hand which bothers me a lot.
Open the program and see the error message and then copy the dlls to folder. Sometimes the error message doesn’t even tell the dll name, only with some vague error message that I need to google myself.
Solution
Use ListDLLs to list all the dlls which our program depends on.
1 | Listdlls v3.2 - Listdlls |
To list the dlls of a program, run the following command:
1 | listdlls example.exe |
The dlls which path starts with mingw are the dlls we want.
The result has some dlls that we don’t care, we can use some cli tools to sort the output for better format.
1 | listdlls example.exe | tail -n +11 | tr -s ' ' | sort -u -k 3 |
Then just copy the dlls and place them aside the exe file.
如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)