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 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 bin path to your PATH so libwinpthread-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.dll from 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 (--static linker flag) to avoid the shared (.dll) dependancy.
1

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

6

When you compile code, add this:

--static

as a parameter to the compilator, it should fix most of dll problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest