Mingw Gives My a Libwinpthread-1. Dll Was Not Found Error When Compiling Code
I Just Downloaded and Installed Mingw. I Also Setup the System Environment Variables for C: \Mingw\Bin and C: \Mingw\Msys\1.0\Bin. I Wanted to Test to See If I...
I just downloaded and installed Mingw. I also setup the system environment variables for C:\MinGW\bin and C:\MinGW\msys\1.0\bin. I wanted to test to see if I had installed it correctly (it seemed to be since running gcc --version worked), so I wrote hellow world in c and tried to compile with gcc main.c -o hello_world.exe. However I got the error:
"The code execution cannot proceed because libewinpthread-1.dll" was not found. Reinstalling the program may fix this problem."
I have tired reinstalling it and restarting my computer. I have also tried to see if this problem has occurred to others, and while there are a few places it is mentioned, I can't seem to find a solution mentioned. I have thought about trying to download the dll separately, but if I remember correctly, downloading dlls is a big no no.
Awhile ago I installed mingw though chocolatey and it seemed to be working. I have deleted that download from my computer and removed the paths, since I wanted to try to install it the normal way. Could this be part of the error?
Any ideas what the issue could be? Thanks!
3 Answers
You have built an .exe file that depends on libwinpthread-1.dll.
Solutions to make sure the .exe can run:
- Add the MinGW
binpath to your PATH solibwinpthread-1.dll- this would only fix it for your own system so I wouldn't recommend this if you want to use the .exe file on other systems. - Copy
libwinpthread-1.dllfrom MinGW in the same folder as your .exe file. This is generally needed for any shared dependancy library your .exe is linked against. - Build a static .exe (
--staticlinker flag) to avoid the shared (.dll) dependancy.
Yes! probably is an error, cause MinGW is a bit stinky when it comes to DLLs
Here are some things you have to check:
Make sure the variable helding the location of MinGW is named "path"
and its pointing at: C:\MinGW64\bin
When you compile code, add this:
--static
as a parameter to the compilator, it should fix most of dll problems